[Mono-dev] sgen garbage collector/unmanaged resources/multi-thread issue

matteo tesser matteo.tesser at gmail.com
Fri Feb 11 09:54:00 EST 2011


I have a concurrent programming test  which during 5-10 minutes
creates and releases a  lot of objects which use unmanaged memory.
Every managed object,  respectively  allocates/deallocates the
unmanaged memory using  Marshal.AllocHGlobal and Marshall.FreeHGlobal
methods  and uses GC.AddMemoryPressure/GC.RemoveMemoryPressure to tell
to  the garbage collector the presence of the additional memory.

I experienced some memory problems on linux,  so I did several tests:

1)  In linux machine with openSuse 11.3 64bit dual core with  mono
2.8.2,  the program launched with mono --gc=sgen eats 4GB of RAM in
about two minutes (see attached screenshot).
If I launch the test by specifying the use of  boehm gc,  the memory
is still consumed but at smaller rate.
I tried the test also with mono 2.10p3 and the behavior is the same
(also using MONO_GC_PARAMS=stack-mark=precise)

2) In Windows/.NET the memory footprint  of the program is constant on
time:  80MB,
3) in a dual core mac os x ( with mono 2.10p2) the behavior is the
same as windows.

4) In a Virtual Machine with  linux openSuse 11.3 32bit  and 1
processor  , mono 2.10p3 the test works fine: the memory footprint  is
constant at 50MB

My conclusion is that the problem is restricted to the linux /
multi-thread case.
Are you aware of such issues on sgen?

I tried to build-up a simple code reproducing the problem but I did
not managed to do it with a simple test case, in case are you
interested in a binary test case?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: sgen.png
Type: image/png
Size: 13409 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110211/3fd12cce/attachment-0001.png 

More information about the Mono-devel-list mailing list