Different Garbage Collection behavior

David Maier <[email protected]> Thu, 25 Aug 2011 04:52:04 -0700
Newsgroups gmane.comp.gnome.mono.garbage-collection
Message-ID <3B8BC0EDFEFA044289217F8618BF1C011AC07D1366@IE2RD2XVS391.red002.local>
Hello,

I have a question regarding the behavior of the Mono Garbage Collector. With .NET the following works quite well:

<code>

long currPhyiscalMemAllocated = _currentProcess.WorkingSet64;
                            
if (currPhyiscalMemAllocated >= 1024*1024*1024) //1GB
{
   _blabla.Flush();
   _blabla = null;

   GC.Collect();
   GC.Collect();
   GC.WaitForPendingFinalizers();

   _blabla = new Blabla();

}

</code>

On Windows and .NET 4 the 'GC.WaitForPendingFinalizers();' causes to wait until the memory, which was previously allocated by _blabla (Let's say this _blabla is a Dictionary), is freed up again. With Mono  2.10.2 and 2.10.5 there is no wait. It finally cause an 'Out Of Memory' Exception. Are there any recommendations or explanations regarding this behavior?

Regards, David

_______________________________________________
Mono-gc-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-gc-list