Garbage collector memory leak "feature"?

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Wed Oct 10 08:49:13 PDT 2007


0ffh wrote:
> 
> More comments on what
> 
> Steven Schveighoffer wrote:
>> 1. Is this just the way all garbage collectors are?  Is there not a 
>> way to solve this problem?
> 
> No, only "conservative" gcs. There are also "exact" gc, but they have one
> big drawback: No void* type at all is possible!

Why would a void* not be possible with an exact gc?
I can see how allocating void[]s could be problematic, but if that were 
disallowed the gc could store exact pointer info for each allocation and 
use that when collecting. (You'd still be able to allocate an array and 
have it implicitly convert to void[], just not allocate it as one 
directly because allocations would need an actual type)

The only issues left then would be static data and the stack.

> So either you want them, then you must use a conservative gc, or you don't
> then you can have an exact gc.
> D wants void*, so there is just no way round.
> 
>> 2. Does Tango have this problem?  I know the GC's are different, and I 
>> use tango, so maybe I could just say, too bad for phobos users and be 
>> on my way 
> 
> Tango is D too, so it must have the same "problem".

I think with proper compiler support, current D can get pretty close to 
supporting an exact gc. Being conservative for arrays allocated as 
void[] might not be such a big issue as data that's definitely 
non-pointer (such as hash values) which is currently searched for 
pointers anyway.

>> 3. If it is solvable, is anyone working on this?  If not, they should 
>> be. Add this to the list of things that need to be fixed before D has 
>> widespread adoption.  Memory leaks == bad bad bad.
> 
> It is not technically correct to call prudently retained memory blocks
> a "memory leak". Those are distinct concepts, in my book at least.

If you can't reach an allocated memory block through some chain of valid 
pointers or references (starting on the stack or in static data), it 
should be deallocated. If it isn't, it's a memory leak. Unfortunately, 
conservative collectors suffer from them.



More information about the Digitalmars-d mailing list