2
我試圖以檢測內存泄漏一MIPS32機器上運行Valgrind的。總可用內存爲32MB(無交換)。問題在於Valgrind本身無法分配他需要的內存量,並且總是生成「內存不足」錯誤。設置內存限制Valgrind的
[email protected]# valgrind --leak-check=yes grep -r "foo" /etc/config/
==9392== Memcheck, a memory error detector
==9392== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==9392== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==9392== Command: grep -r foo /etc/config/
==9392==
==9392==
==9392== Valgrind's memory management: out of memory:
==9392== initialiseSector(TC)'s request for 27597024 bytes failed.
==9392== 20516864 bytes have already been allocated.
==9392== Valgrind cannot continue. Sorry.
==9392==
==9392== There are several possible reasons for this.
==9392== - You have some kind of memory limit in place. Look at the
==9392== output of 'ulimit -a'. Is there a limit on the size of
==9392== virtual memory or address space?
==9392== - You have run out of swap space.
==9392== - Valgrind has a bug. If you think this is the case or you are
==9392== not sure, please let us know and we'll try to fix it.
==9392== Please note that programs can take substantially more memory than
==9392== normal when running under Valgrind tools, eg. up to twice or
==9392== more, depending on the tool. On a 64-bit machine, Valgrind
==9392== should be able to make use of up 32GB memory. On a 32-bit
==9392== machine, Valgrind should be able to use all the memory available
==9392== to a single process, up to 4GB if that's how you have your
==9392== kernel configured. Most 32-bit Linux setups allow a maximum of
==9392== 3GB per process.
==9392==
==9392== Whatever the reason, Valgrind cannot continue. Sorry.
我想知道的是,如果有可能限制Valgrind分配的內存量。我試着玩--max-stacksize和--max-stackframe,但結果總是一樣的。
結帳這篇文章增加了Valgrind的內存限制:http://sourceforge.net/p/valgrind/mailman/message/27779126/ 你可能可以降低限制,做基本相同的事情。 – 2014-11-05 17:44:15
32MB非常小。假設操作系統和其他進程需要一些內存,並且你的應用程序需要一些本身,這對valgrind來說並沒有太多的幫助。 – 2014-11-05 17:47:00