Who wants to have some fun memory debugging?

Robert Fraser fraserofthenight at gmail.com
Tue May 12 23:23:06 PDT 2009


Sean Kelly wrote:
> At this point it's quite possible that you still have a reference to 
> newData in a register.  

That argument works for one iteration, but this fool just keeps on 
growing. Also, this is a pared down test from a much larger program, so 
this is unlikely.

> If you want to be sure the collect call below 
> works as intended for this test, try adding:
> 
>           newData = new Data;
> 
> here.
> 
>>         i = 0;
>>         GC.collect();
>>     }
>> }

Nope, didn't do anything. It still swells forever.

> Beyond that, you'll just potentially end up with a bunch of false 
> positives, since you have a big static array in the same block as a 
> pointer.  But since you aren't actually setting the array contents in 
> this test, that clearly isn't a problem here.

The real program is a tree structure that contains class references, so 
is entirely pointers. The root of the tree is then discarded, and a new 
tree created, however the old tree isn't being collected.


More information about the Digitalmars-d-learn mailing list