-
March 13th, 2009, 09:48 AM
#1
Memory leak detection in linux applications
Please let me know, how to detect if the application has memory leak in linux platform. Which command/tool and what counters to track ?
-
March 13th, 2009, 09:49 AM
#2
Re: Memory leak detection in linux applications
Run the program (compiled with debug symbols) through valgrind. It will report any questionable memory-related actions, including leaks.
-
March 13th, 2009, 10:42 AM
#3
Re: Memory leak detection in linux applications
Thanks for you suggestion. Before doing that, is there any reliable linux utility, by which i can confirm if there application really leaks memory ?
-
March 13th, 2009, 11:53 AM
#4
Re: Memory leak detection in linux applications
Valgrind is the solution to that too. Valgrind is God for linux development.
-
March 14th, 2009, 01:50 PM
#5
Re: Memory leak detection in linux applications
Lindley: agreed, it often even helps me find the cause of segfaults faster than gdb...
htonivi: You may have to compile your code with debug symbols using -g to get backtraces (more detail). This might not be required though (it is when using gdb).
Then:
Code:
gcc -g -o yourprog yourprog.c
valgrind --tool=memcheck --leak-check=full ./yourprog
Note that your code will run way slower under Valgrind, of course, since it's doing a lot of run-time checking. If some of the backtraces are "optimized out" as you see with gdb, compile without optimizations (-O0).
Last edited by lanctot; March 14th, 2009 at 01:53 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|