0
我正在ARMv7-A計算機上運行應用程序,Fedora 18,2GB內存。mmap2未能爲線程分配堆棧,但在GDB下工作
應用程序終止:
130413 15:49:34 19344 Xrd: PhyConnection: Can't run reader thread: out of system resources. Critical error.
如果我strace
,我看到堆棧分配一個新的線程失敗:
mmap2(NULL, 8388608, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = -1 ENOMEM (Cannot allocate memory)
gettimeofday({1365921367, 588018}, NULL) = 0
gettid() = 6309
writev(2, [{"130414 02:36:07 6309 ", 21}, {"Xrd", 3}, {"", 0}, {": ", 2}, {"PhyConnection: Can't run reader "..., 80}, {"\n", 1}], 6130414 02:36:07 6309 Xrd: PhyConnection: Can't ru
n reader thread: out of system resources. Critical error.
) = 107
munmap(0x48172000, 292) = 0
munmap(0x48225000, 292) = 0
實際代碼:
253 if (fReaderthreadhandler[i]->Run(this)) {
254 Error("PhyConnection",
255 "Can't run reader thread: out of system resources. Critical error.");
256 // HELP: what do we do here
257 exit(-1);
258 }
的應用程序的虛擬內存大小爲300-350MB,而駐留內存大小爲〜250MB。高內存限制爲1.3GB。虛擬地址空間不受限制:
-t: cpu time (seconds) unlimited
-f: file size (blocks) unlimited
-d: data seg size (kbytes) unlimited
-s: stack size (kbytes) 8192
-c: core file size (blocks) 0
-m: resident set size (kbytes) unlimited
-u: processes 1024
-n: file descriptors 1024
-l: locked-in-memory size (kbytes) 64
-v: address space (kbytes) unlimited
-x: file locks unlimited
-i: pending signals 15870
-q: bytes in POSIX msg queues 819200
-e: max nice 0
-r: max rt priority 0
-N 15: unlimited
但它確實從GDB工作!我也看了GDB報道的限制,他們是一樣的。因此,GDB不會調整將被繼承的軟限制。
摘要:
- 我有足夠的內存來運行應用程序。它甚至可以在GDB內正常工作。
- 它似乎並沒有達到任何資源限制。
- 在廣東發展局工作,但不在外面。
這裏有什麼可能是錯誤的提示?
[Fedora 18](http://en.wikipedia.org/wiki/List_of_Fedora_versions#Fedora_18)是Linux 3.6.10 –
你試過'ulimit -s unlimited'嗎?顯然,** MAP_STACK **應該不重要,但限制爲8M。這只是一個猜測。很明顯,'mmap'失敗了,所以我想理解爲什麼內核返回* ENOMEM *。 ** GDB **可能會改變程序設置,如堆棧。 –
除了總內存消耗之外,還有更多限制:'ENOMEM沒有內存可用,或者進程的最大映射數量已被超過。 – wildplasser