Перевірка С-програм під Linux на витоки пам’яті
Перевірка програм написаних на С під Linux на витоки пам’яті та профілювання
Використовуємо valgrind
$ valgrind --leak-check=yes ./myapp arg1 arg2
$ valgrind --leak-check=yes /path/to/myapp arg1 arg2
Використвуємо журнал
$ valgrind --log-file=log.file --leak-check=yes --tool=memcheck
./myapp arg1 arg2
Приклад результату виводу:
$ valgrind --leak-check=yes date
==1677== Memcheck, a memory error detector.
==1677== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==1677== Using LibVEX rev 1854, a library for dynamic binary translation.
==1677== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==1677== Using valgrind-3.3.1-Debian, a dynamic binary
instrumentation framework.
==1677== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==1677== For more details, rerun with: -v
==1677==
Sat May 1 19:30:50 EEST 2010
==1677==
==1677== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 8 from 1)
==1677== malloc/free: in use at exit: 0 bytes in 0 blocks.
==1677== malloc/free: 15 allocs, 15 frees, 2,176 bytes allocated.
==1677== For counts of detected errors, rerun with: -v
==1677== All heap blocks were freed -- no leaks are possible.
Читайте також:
- Linux Commands For Shared Library Management and Debugging Problem
- Synaptics Touchpad в Linux
- Google Translate API From The Command Line
- RTL SDR on Mac OS X
- vsftpd /bin/false check_shell=NO pam hack
- How To capture video from tv-tuner card via mencoder
- ssh daemon on Android with dropbear
- Clearing caches from memory
- etc snapshots with git
- Howto install decklink driver of blackmagicdesign on gentoo linux