Garbage collector noob

torhu fake at address.dude
Wed Mar 7 23:37:26 PST 2007


Sean Kelly wrote:
> Windows.  The app jumps to 467k almost immediately and stays there.  I 
> haven't tried stepping through the loop, so it may just be happening too 
> fast for me to see.

I assume you mean 467MB?  Anyway, the point is not how fast it happens. 
  The problem is that it happens at all.  I expected to be able to use 
the garbage collector to keep the test app's memory at ~40MB.  If 
std.gc.minimize doesn't do that, then how is it different from 
std.gc.fullCollect?

By the way, the limit for how much memory size grows when running the 
test app depends on the size of the array.  So the GC seems to set a 
limit based on the app's typical allocation sizes.  Which makes sense 
and probably keeps allocation speeds up.

It might be that I should start viewing the GC more as a leak preventor 
than a simpler way of keeping memory usage down.  Simpler than explicit 
deallocation, that is.  The GC might decide to let memory usage grow to 
what the programmer or the user consider unreasonable sizes.  So 
basically, you should always use delete or scope to free memory, since 
when the GC does it, it will be a bit late.


More information about the Digitalmars-d-learn mailing list