new D2.0 + C++ language

BCS ao at pathlink.com
Fri Mar 20 10:15:43 PDT 2009


Reply to Weed,

> BCS ?????:
> 
>> Hello Weed,
>> 
>>> 
>>> Mmm
>>> When I say "overhead" I mean the cost of executions, and not cost of
>>> programming
>> So do I.
>> 
>> I figure unless it save me more times than it costs /all/ the users,
>> run time cost trumps.
>> 
> This is a philosophical dispute.
> 
> A good and frequently used code can be written once and then used 10
> years in 50 applications in 10000 installations. Here, the costs of
> programming may be less than the cost of end-user's time and hardware.
> 

You are agreeing with me.

>> 
>> As for memory, unless the thing overspends into swap and does so very
>> quickly (many pages per second) I don't think that matters. This is
>> because most of the extra will not be part of the resident set so the
>> OS will start paging it out to keep some free pages. This is
>> basically free until you have the CPU or HDD locked hard at 100%. The
>> other half is that the overhead of reference counting and/or the like
>> will cost in memory (you have to store the count somewhere) and might
>> also have bad effects regarding cache misses.
>> 
>
> Once again I repeat: forget about reference counting - it is only for
> the debug purposes. I think this addition should be switchable by
> compiler option.
> 
> It did not included into the resulting code. Ref-counting needed for
> multithreaded programs, when there is a risk to get and use a
> reference to an object that another process has already been killed.
> This situation needs to be recognized and issued to a run-time error.

As I understand the concept "reference counting" is a form of GC. It has 
nothing to do with threading. The point is to keep track of how many references, 
in any thread, there are to a dynamic resource and to free it when there 
are no more. Normally (as in if you are not doing things wrong) you never 
release/free/delete a reference counted resource so it doesn't even check 
if it is delete. Also because the count is attached to the referenced resource, 
it can't do that check because the count is deleted right along with it.

For that concept (the only meaning of the term "reference counting" I known 
of) the idea of turning it off for non-debug builds is silly. Are you referring 
to something else?





More information about the Digitalmars-d mailing list