2014-11-05 1 views
2

메모리 누수를 감지하기 위해 mips32 시스템에서 Valgrind를 실행하려고합니다. 사용 가능한 총 메모리는 32MB입니다 (SWAP 사용 안 함). 문제는 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을 가지고 놀려고했지만 결과는 항상 같습니다.

+0

Valgrind의 메모리 제한을 늘리려면이 게시물을 확인하십시오. http://sourceforge.net/p/valgrind/mailman/message/27779126/ 기본적으로 동일한 작업을 수행하면 제한을 낮출 수 있습니다. –

+1

32MB가 너무 작습니다. OS 및 다른 프로세스가 메모리를 필요로한다고 가정하고 valgrind가 작동하도록하기 위해 앱을 많이 사용하지 않는 앱이 필요합니다. –

답변

0

의견에서 언급했듯이 32MB는 그리 많지 않습니다. OS 및 기타 필요한 프로세스를 다루어야합니다. Valgrind/Memcheck를 사용하여 프로그램을 분석 할 때 프로그램 자체가 수행하는 것보다 두 배 이상의 메모리가 필요합니다. 이는 Memcheck이 모든 할당 된 비트에 대해 그림자 값을 저장하므로 초기화되지 않은 변수를 인식 할 수 있기 때문입니다.

필자는 데스크톱 컴퓨터 용 프로그램을 컴파일하고 Memcheck를 실행하는 것이 가장 좋은 해결책이라고 생각합니다. 프로그램에 누수, 초기화되지 않은 변수 등이있는 경우 데스크탑 컴퓨터에도 누출이 있습니다.

프로그램이 MIPS에서 어떻게 작동하는지 궁금하다면 Massif (시간 경과에 따른 힙 측정) 및 Cachegrind (캐시 성능)와 같은 다른 Valgrind 도구로 분석하십시오. 그것들은 Memcheck보다 훨씬 가볍습니다.