Browsed by
Category: C++

[Linux] How to check if program has memory leaks

[Linux] How to check if program has memory leaks

You can check your program using command: valgrind your_programvalgrind your_program Example of usage: We have following C++ program (tst.cpp): int main() { int * tab = new int[1000000]; return 0; }int main() { int * tab = new int[1000000]; return 0; } Obviously it generates memory leak. We compile it to tst file and execute: valgrind tstvalgrind tst