I am running my mono application at a bitnami linux with 8 GB of memory. It is a sophisticated file merger application, which is supposed to take a lot of RAM as it works.
But every time it takes more than 4 GB of RAM, it crashes with following error message:
Too many heap sections: Increase MAXHINCR or MAX_HEAP_SECTS
Stacktrace:
at (wrapper managed-to-native) object.__icall_wrapper_mono_array_new_specific (intptr,int) <0x0005e>
at (wrapper managed-to-native) object.__icall_wrapper_mono_array_new_specific (intptr,int) <0x0005e>
at System.Collections.Generic.Dictionary`2<string, System.Nullable`1<int>>.InitArrays (int) <0x00040>
at System.Collections.Generic.Dictionary`2<string, System.Nullable`1<int>>.Init (int,System.Collections.Generic.IEqualityComparer`1<string>) <0x00091>
at System.Collections.Generic.Dictionary`2<string, System.Nullable`1<int>>..ctor () <0x0001b>
at lawyerGatherBot.Merger.LawyerRepresentation..ctor (string) <0x00080>
at lawyerGatherBot.Merger.MergeLawyerRecords.Map (System.Collections.Generic.IEnumerable`1<string>) <0x00167>
at lawyerGatherBot.Program.Main (string[]) <0x00161>
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <0x00082>
Native stacktrace:
mono() [0x48bd6b]
/lib/libpthread.so.0(+0xf8f0) [0x7f6c4198a8f0]
/lib/libc.so.6(gsignal+0x35) [0x7f6c4162ba75]
/lib/libc.so.6(abort+0x180) [0x7f6c4162f5c0]
mono() [0x5da188]
mono() [0x5d7ec0]
mono() [0x5d8349]
mono() [0x5d8534]
mono() [0x5d86f1]
mono() [0x5d3571]
mono() [0x5d4752]
mono() [0x5d50e5]
mono(mono_array_new_specific+0xba) [0x53716a]
[0x40df9f2f]
Debug info from gdb:
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Aborted
Here’s the output of mono -V :
Mono JIT compiler version 2.8.2 (tarball Tue Aug 30 18:06:04 UTC 2011)
Copyright (C) 2002-2010 Novell, Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: debugger softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
What should I do to be able to run memory-intensive apps on mono?
*UPDATE
I screw up and compiled the app for 32 bit systems. Hence, this error.
My understanding is that this error stems from the Boehm GC.
Try this first. Download and build from source using the script below. In the configure part of the script, make this change:
./configure –with-large-heap=yes
Do this in addition to whatever other config issues you want to set. This should set the LARGE_CONFIG flag.
If you wanted to set it manually (I don’t know why), here are the steps:
http://www.integratedwebsystems.com/2011/08/install-mono-2-10-3-on-ubuntu-using-bash-script/
build/mono-2.10.8/libgc/include/gc_config_macros.h
make
sudo make install
Hopefully this will compile a new mono that solves your problem. The resulting mono will be in /opt
Some of the most affected code is in libgc/include/private/gc_priv.h, but the maintainers have nicely put conditionals all over for the LARGE_CONFIG flag, so it’s probably best to work with that.