Embedded Linux software for eating memory is more taboo, embedded device memory is more valuable.
In the usual coding process, we often need to check the problem of memory leaks, if by
Experience to do, a line of code checking, the effect is not very good, often missing.
Valgrind is a better open source project for detecting memory leaks:
Http://valgrind.org/docs/download_docs.html, this is its official help document, more comprehensive
Another Netizen wrote a blog about how to use Valgrind, yes, you can refer to:
Http://blog.csdn.net/zhoujunyi/archive/2007/09/11/1780749.aspx
I would like to emphasize that:
Memory leak detection should be done in a normal job, such as the Gnome Power Manager, the Open source project
is to use valgrind as a normal detection tool, writing a script:
valrind_gpm.sh
The contents are as follows:
Killall Gnome-power-manager
Export G_slice=always-malloc
Export g_debug=gc-friendly
Valgrind--tool=memcheck--leak-check=full--leak-resolution=high./gnome-power-manager--verbose--no-daemon-- Timed-exit &>/debug-valgrind.log
This allows you to run the following valgrind_gpm.sh script in a timely manner after the code is compiled, and instantly check
After the program changes the memory abnormality problem, can arrive in time discovers the problem, solves the problem. The program will become more and more stable.
This is worth our reference, memory detection to do in peacetime, to solve the problem of light eating not spit, indigestion.