Linux uses valgrind to detect program memory leakage

Source: Internet
Author: User

1. download the latest valgrind from http://valgrind.org/

2. After pressurization, you can view the README file and follow the instructions in readme to perform the following operations:

1). Run./configure, with some options if you wish. The only interesting
One is the usual -- prefix =/where/you/want/IT/installed.

2). Run "make ".

3). Run "make install", possibly as root if the destination Permissions
Require that .---Ubuntu requires the root permission, that is, run: sudo make install

4). See if it works. Try "valgrind LS-L". Either this works, or it
Bombs out with some complaint. In that case, please let us know
(See www.valgrind.org ).

The following errors may occur:

Valgrind: Fatal error at startup: A function redirectionvalgrind: which is mandatory for this platform-tool combinationvalgrind: cannot be set up. details of the redirection are: valgrind: A must-be-redirected functionvalgrind: Whose name matches the pattern: indexvalgrind: In an object with soname matching: ld-linux.so.2valgrind: was not found whilst processingvalgrind: symbols from the object with soname: ld-linux.so.2valgrind: valgrind: possible fixes: (1, short term): Install glibc's debuginfovalgrind: Package on this machine. (2, longer term): Ask the packagersvalgrind: For your Linux distribution to please in future ship a non-valgrind: Stripped lD. so (or whatever the dynamic linker. so is called) valgrind: that exports the above-named function using the standardvalgrind: calling conventions for this platform. the package you needvalgrind: to install for fix (1) is calledvalgrind: valgrind: On Debian, Ubuntu: libc6-dbgvalgrind: On Suse, opensuse, fedora, RHEL: Glibc-debuginfovalgrind: valgrind: cannot continue -- exiting now. sorry.

The above error is because a Lib: libc6-dbg is also required under Ubuntu

Run: sudo apt-Get install libc6-dbg to install libc6-dbg

Run valgrind LS-l again.

 

You can use it as follows:

Valgrind -- tool = memcheck -- leak-check = full./Hellworld

 

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.