2011-12-28 1 views
16

파일 fifo.hfifo.c에 FIFO 목록 (큐)의 pure-C 구현을 개발했으며 ./bin/testfifo으로 컴파일하는 테스트 프로그램 testfifo.c을 작성했습니다. 노드 구조는 list.h에 정의됩니다.Valgrind에서 억압 된 누출은 무엇을 의미합니까?

나는이

valgrind --tool=memcheck --leak-check=full --show-reachable=yes ./bin/testfifo 

처럼 OS X 10.6에 Valgrind의를 통해 내 프로그램을 실행하고 다음과 같은 출력

==54688== Memcheck, a memory error detector 
==54688== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. 
==54688== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info 
==54688== Command: bin/testfifo 
==54688== 
--54688-- bin/testfifo: 
--54688-- dSYM directory is missing; consider using --dsymutil=yes 
==54688== 
==54688== HEAP SUMMARY: 
==54688==  in use at exit: 88 bytes in 1 blocks 
==54688== total heap usage: 11 allocs, 10 frees, 248 bytes allocated 
==54688== 
==54688== LEAK SUMMARY: 
==54688== definitely lost: 0 bytes in 0 blocks 
==54688== indirectly lost: 0 bytes in 0 blocks 
==54688==  possibly lost: 0 bytes in 0 blocks 
==54688== still reachable: 0 bytes in 0 blocks 
==54688==   suppressed: 88 bytes in 1 blocks 
==54688== 
==54688== For counts of detected and suppressed errors, rerun with: -v 
==54688== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) 

를 얻을 누출 요약에 따르면, 누출이없는,하지만, 난 여전히입니다 "억압 된"누수가 무엇인지 궁금해합니다. 게다가 alloc과 free의 수는 일치하지 않으므로 누수가 있는지 없는지 확실하지 않습니다. OS에

valgrind --tool=memcheck --leak-check=full --show-reachable=yes -v ./bin/testfifo 

실행

---- 편집 ----

는 X 10.6은 상당히 길고 복잡한 출력을 생성합니다,하지만 난

valgrind --tool=memcheck --leak-check=full --show-reachable=yes ./bin/testfifo 

를 실행 한 리눅스 머신이 출력을 가지고 있습니다 :

==32688== Memcheck, a memory error detector 
==32688== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al. 
==32688== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info 
==32688== Command: bin/testfifo 
==32688== 
==32688== 
==32688== HEAP SUMMARY: 
==32688==  in use at exit: 0 bytes in 0 blocks 
==32688== total heap usage: 10 allocs, 10 frees, 160 bytes allocated 
==32688== 
==32688== All heap blocks were freed -- no leaks are possible 
==32688== 
==32688== For counts of detected and suppressed errors, rerun with: -v 
==32688== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4) 

alloc과 free는 이제과 일치하므로 OS X의 추가 할당은 일부 시스템 라이브러리 때문인 것으로 보입니다.

억제 된 오류 4 개를 나타 내기 위해 -v 옵션과 동일한 명령을 실행했지만 쉽게 이해할 수있는 새로운 정보가 없습니다.

답변

20

이는 코드 외부, (아마도 공유 된) 라이브러리 또는 알려진 가양 성의 누수입니다. -v으로 valgrind를 실행하면 사용 된 억압에 대해 알려야합니다.

+7

오류 검사 도구는 OS에 사전 설치되어있는 C 라이브러리와 같은 시스템 라이브러리의 수많은 문제를 감지합니다. 이 오류를 쉽게 고칠 수는 없지만 이러한 오류를보고 싶지는 않습니다 (예, 많습니다!) 따라서 Valgrind는 시작할 때 표시되지 않도록 오류 목록을 읽습니다. 기본 억제 파일은 시스템이 빌드 될 때 ./configure 스크립트에 의해 작성됩니다. – Sjoerd

+2

일부는 라이브러리 문제가 아니지만 응용 프로그램 외부의 프로세스간에 메모리를 공유하는 것으로 알려진 라이브러리의 경우도 있습니다. –

+0

@MichaelMior 그래, 나는 memcheck와 false positive를 보아왔다. – cnicutar