我在 8 GB 内存的 bitnami linux 上运行我的单声道应用程序。这是一个复杂的文件合并应用程序,它在工作时应该占用大量 RAM。 但每次需要超过 4 GB 的 RAM 时,它都会崩溃并显示以下错误消息:
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
这是 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)
我应该怎么做才能在单声道上运行内存密集型应用程序?
*更新 我搞砸了并为 32 位系统编译了应用程序。因此,这个错误。
最佳答案
我的理解是这个错误源于Boehm GC。
先试试这个。使用下面的脚本从源代码下载和构建。在脚本的配置部分,进行以下更改:
./configure --with-large-heap=yes
除了您要设置的任何其他配置问题之外,还要执行此操作。这应该设置 LARGE_CONFIG 标志。
如果你想手动设置它(我不知道为什么),步骤如下:
- 在此处下载单声道源代码并运行脚本
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
#ifndef LARGE_CONFIG
#define LARGE_CONFIG
#endif
- 现在转到build/mono-2.10.8 并运行
制作 须藤安装
希望这会编译一个新的单声道来解决您的问题。生成的单声道将在/opt
一些受影响最大的代码在 libgc/include/private/gc_priv.h 中,但是维护者很好地为 LARGE_CONFIG 标志设置了条件语句,因此最好使用它。
关于c# - Mono:堆部分太多当应用程序占用内存超过 4 GB 时增加 MAXHINCR 或 MAX_HEAP_SECTS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7248980/