我在開羅搞亂並且很快意識到,即使只是定期鏈接庫(-I/usr/include/cairo)而不使用它或者分配任何東西都會導致內存泄漏。 有沒有人有這個問題?有沒有一個特定的cairo特定的代碼,我需要包括在鏈接時避免泄漏?開羅鏈接導致內存泄漏
樣品Hello World程序:
#include <stdio.h>
int main(){
printf("Hello, world!\n");
return 0;
}
定期編譯:
的gcc -o測試test.c的-Wall
Hello, world!
==19531==
==19531== HEAP SUMMARY:
==19531== in use at exit: 0 bytes in 0 blocks
==19531== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==19531==
==19531== All heap blocks were freed -- no leaks are possible
==19531==
==19531== For counts of detected and suppressed errors, rerun with: -v
==19531== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
鏈接開羅:
的gcc -o test test.c -Wall $(pkg-config --cflags --libs cairo)
Hello, world!
==19538==
==19538== HEAP SUMMARY:
==19538== in use at exit: 12,384 bytes in 6 blocks
==19538== total heap usage: 6 allocs, 0 frees, 12,384 bytes allocated
==19538==
==19538== LEAK SUMMARY:
==19538== definitely lost: 0 bytes in 0 blocks
==19538== indirectly lost: 0 bytes in 0 blocks
==19538== possibly lost: 0 bytes in 0 blocks
==19538== still reachable: 12,384 bytes in 6 blocks
==19538== suppressed: 0 bytes in 0 blocks
==19538== Rerun with --leak-check=full to see details of leaked memory
==19538==
==19538== For counts of detected and suppressed errors, rerun with: -v
==19538== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
泄漏檢查=全:
valgrind ./test --leak-check=full -v --tool=memcheck
==20390== Memcheck, a memory error detector
==20390== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==20390== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==20390== Command: ./test --leak-check=full -v --tool=memcheck
==20390==
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/ld-2.22.so:
--20390-- Ignoring non-Dwarf2/3/4 block in .debug_info
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/ld-2.22.so:
--20390-- Last block truncated in .debug_info; ignoring
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/ld-2.22.so:
--20390-- parse_CU_Header: is neither DWARF2 nor DWARF3 nor DWARF4
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/libc-2.22.so:
--20390-- Ignoring non-Dwarf2/3/4 block in .debug_info
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/libc-2.22.so:
--20390-- Ignoring non-Dwarf2/3/4 block in .debug_info
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/libc-2.22.so:
--20390-- Ignoring non-Dwarf2/3/4 block in .debug_info
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/libc-2.22.so:
--20390-- Last block truncated in .debug_info; ignoring
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/libc-2.22.so:
--20390-- parse_CU_Header: is neither DWARF2 nor DWARF3 nor DWARF4
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/librt-2.22.so:
--20390-- Ignoring non-Dwarf2/3/4 block in .debug_info
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/librt-2.22.so:
--20390-- Last block truncated in .debug_info; ignoring
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/librt-2.22.so:
--20390-- parse_CU_Header: is neither DWARF2 nor DWARF3 nor DWARF4
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/libm-2.22.so:
--20390-- Ignoring non-Dwarf2/3/4 block in .debug_info
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/libm-2.22.so:
--20390-- Last block truncated in .debug_info; ignoring
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/libm-2.22.so:
--20390-- parse_CU_Header: is neither DWARF2 nor DWARF3 nor DWARF4
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/libdl-2.22.so:
--20390-- Ignoring non-Dwarf2/3/4 block in .debug_info
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/libdl-2.22.so:
--20390-- Last block truncated in .debug_info; ignoring
--20390-- WARNING: Serious error when reading debug info
--20390-- When reading debug info from /lib/x86_64-linux-gnu/libdl-2.22.so:
--20390-- parse_CU_Header: is neither DWARF2 nor DWARF3 nor DWARF4
Hello, world!
==20390==
==20390== HEAP SUMMARY:
==20390== in use at exit: 12,384 bytes in 6 blocks
==20390== total heap usage: 6 allocs, 0 frees, 12,384 bytes allocated
==20390==
==20390== LEAK SUMMARY:
==20390== definitely lost: 0 bytes in 0 blocks
==20390== indirectly lost: 0 bytes in 0 blocks
==20390== possibly lost: 0 bytes in 0 blocks
==20390== still reachable: 12,384 bytes in 6 blocks
==20390== suppressed: 0 bytes in 0 blocks
==20390== Rerun with --leak-check=full to see details of leaked memory
==20390==
==20390== For counts of detected and suppressed errors, rerun with: -v
==20390== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
更新了完整的漏洞檢查問題,它絕對沒有洞察力。 – Chirality
那麼,因爲它不是__ you__誰沒有釋放,並且對其他系統或圖書館活動沒有太多可以做的事情,所以你可能應該停止引起自己的焦慮。除非你能確切地確定誰正在分配12K以及是否可以做任何事情。 –
我寧願強調自己。 – Chirality