Valgrind do the normal memory leak check

Source: Internet
Author: User
Tags valgrind


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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.