Перевірка С-програм під 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
- bash history - відображення дати і часу для кожної команди
- Howto install and use usb modem, as example "mts connect", in debian linux
- How To quick generate openssl certificate signing request
- Apache: No space left on device: Couldn't create accept lock
- etc snapshots with git
- Google Translate API From The Command Line
- /usr/bin/ld: cannot find -lstdc++ Debian libreadline5-dev package bug
- How To capture video from tv-tuner card via mencoder
- Запуск декількох X сесій