Friday, January 18, 2008

Linux - Memory Leakage

In Linux the valgrind tool help us to detect the memory leakage in our coding.

For Example
if your application exec is named as myexec, then run the command as below

valgrind --tool=memcheck --leak-check=yes --num-callers=25 ./myexec

Note :- when your running the exec with valgrind tool run the exec with ./ (dot slash).

when your application needs to pass arguments with the exec run tool with argument

valgrind --tool=memcheck --leak-check=yes --num-callers=25 ./myexec -ORBInitRef NameServic=corbaloc:iiop:localhost/NameService


Memcheck performs a range of memory-checking functions,including detecting accesses to uninitialized memory, misuse of allocated memory (double frees, access after free, etc.) and detecting memory leaks.

Note : use the latest tool version to get the best performance.

No comments: