dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pnet-developers] explicit calls to GC.Collect() vs letting GC take care


From: Tim Nichols
Subject: [Pnet-developers] explicit calls to GC.Collect() vs letting GC take care of itself.
Date: Mon, 17 Apr 2006 23:13:29 -0700
User-agent: Thunderbird 1.5 (Windows/20051201)

Hi -

In my application, I've found that if I explicitly induce a garbage collection by calling GC.Collect() periodically, the amount of memory used stays fairly constant (as expected). However, if I do not periodically force a GC and allow the GC to collect when it thinks it needs it, eventually I'll get an OutOfMemoryException, even if I set GC_max_retries = 2 in lib_gc/alloc.c. For example, if I call GC.Collect() periodically, I'll see about 2MB being used in my application. If I let GCs happen naturally, memory will climb much higher than 2MB (as expected) but it will never drop the memory usage back to 2MB after a collection, it will be more like 2.5MB. I would expect it to drop it down to 2MB as in the other case. What ends up happeniing is that next time the GC decides to collect, the new floor becomes 2.75MB, then 3MB, etc until eventually it runs out of memory.

Why would the memory behavior be so different if I force a GC vs letting the GC just take care of itself?

I can't imagine it is due to a leak, otherwise the frequent calls to GC.Collect() wouldn't show a constant memory footprint - it would slowly fill up memory as well.

Thanks in advance for any insight.

- Tim


reply via email to

[Prev in Thread] Current Thread [Next in Thread]