Garbage collector memory leak "feature"?

Steven Schveighoffer schveiguy at yahoo.com
Wed Oct 10 09:11:41 PDT 2007


"Steven Schveighoffer" wrote
> Something has come to light in a few posts that has described memory leak 
> problems because the garbage collector finds ghost pointers in hash data. 
> My understanding of the problem is that the garbage collector marks data 
> allocations as having pointers or not having pointers, and then searches 
> through all the data to see if there are any valid pointers, finding data 
> that looks like a pointer, but is not.

Here's another reason why this is no good.  A copying garbage collector (as 
described on the D garbage collection page 
http://www.digitalmars.com/d/garbage.html) would not be possible.  Imagine 
using a hash value that happens to look like a valid pointer.  The copying 
garbage collector comes along and tries to compact the data, and in doing so 
moves the data that is "pointed to" by this hash code.  It would then change 
the hash code to point to the new data!

-Steve 





More information about the Digitalmars-d mailing list