Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Mono crashes in such test case:
public static void Main(string args)
List<byte> test = new List<byte>();
for (int i=0; i<int.MaxValue; i++)
* Assertion at sgen-gc.c:2221, condition `mem' not met
at (wrapper managed-to-native) object.__icall_wrapper_mono_gc_alloc_vector (intptr,intptr,intptr) <0xffffffff>
at (wrapper alloc) object.AllocVector (intptr,intptr) <0xffffffff>
at mt3.MainClass.Main (string) <0x0004b>
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <0xffffffff>
instead of crashing mono should raise OutOfMemory exception
Mono JIT compiler version 22.214.171.124 (Debian 126.96.36.199-1~dhx1~lucid1)
Ubuntu 10.04 (32 bit)
4Gb of RAM
I ran this test case in mono 3.0.4. The result is correct.
[ERROR] FATAL UNHANDLED EXCEPTION: System.OutOfMemoryException: Out of memory
at (wrapper managed-to-native) object:__icall_wrapper_mono_gc_alloc_vector (intptr,intptr,intptr)
at (wrapper alloc) object:AllocVector (intptr,intptr)
at mt3.MainClass.Main (System.String args) [0x00000] in <filename unknown>:0
Mono JIT compiler version 3.0.4 (master/0e6393e Mon Feb 4 14:03:01 PST 2013)
Ubuntu 12.04 (32 bit)
768M of RAM
Also, I noticed difference in memory allocation. mono-sgen 2.10.8 allocates only free memory, without using swap and crashes in case of out of memory. mono-sgen 3.0.4 allocates free memory and whole free swap and only then throw OutOfMemoryException or was killed by oom killer.
mono does alloc as much memory as you let it to. This is the normal behavior of any program you run.
I suggest you limit the amount of managed memory mono can allocate and in the meanwhile try to find the memory leaks in your app.
I don't understand your point. Do you mean, that hard crash of mono instead of throwing OutOfMemoryException is normal behaviour? In this bug I didn't tell about memory leaks, what I've just said, that mono 2.10 must throw OutOfMemoryException when there is no enough memory but not to crash.
Use mono 3.0.0. 2.10 is not longer publicly maintained.