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