Installation and Operation of valgrind-3.4.1 in AIX5.3

Source: Internet
Author: User
Tags valgrind

After 48 hours of efforts, finally completed the installation of the valgrind-3.4.1 AIX5.3, now summarize to you.

 

1) An example of illegal access to memory and Memory leakage is as follows:

# Include <stdlib. h>

Void fun ()
{
Int * p = (int *) malloc (10 * sizeof (int ));
P [10] = 'a ';
}

Int main (int argc, char * argv [])
{
Printf ("begin to leak \ n ");
Fun ();
Printf ("leak a lot \ n ");
Return 0;
}

 

2) We use valgrind for check

Valgrind -- tool = memcheck./A. Out
==7729550 = Memcheck, a memory error detector.
= 7729550 = Copyright (C) 2002-2008, and gnu gpl 'd, by Julian Seward et al.
= 7729550 = Using LibVEX rev 1884, a library for dynamic binary translation.
= 7729550 = Copyright (C) 2004-2008, and gnu gpl 'd, by OpenWorks LLP.
= 7729550 = Using valgrind-3.4.1, a dynamic binary instrumentation framework.
= 7729550 = Copyright (C) 2000-2008, and gnu gpl 'd, by Julian Seward et al.
= 7729550 = For more details, rerun with:-v
= 7729550 =
Begin to leak
==7729550 = Invalid write of size 4
= 7729550 = at 0x00004d4: leak (in/proc/7729550/object/a. out)
==7729550 = by 0x000052f: main (in/proc/7729550/object/a. out)
= 7729550 = Address 0x216a4050 is 0 bytes after a block of size 40 alloc 'd
= 7729550 = at 0xDD1ED5B0: malloc (vg_replace_malloc.c: 207)
= 7729550 = by 0x00004bb: leak (in/proc/7729550/object/a. out)
==7729550 = by 0x000052f: main (in/proc/7729550/object/a. out)
Leak a lot
= 7729550 =
= 7729550 = error summary: 1 errors from 1 contexts (suppressed: 0 from 0)
= 7729550 = malloc/free: in use at exit: 40 bytes in 1 blocks.
= 7729550 = malloc/free: 1 allocs, 0 frees, 40 bytes allocated.
= 7729550 = For counts of detected errors, rerun with:-v
= 7729550 = searching for pointers to 1 not-freed blocks.
= 7729550 = checked 9,012,008 bytes.
= 7729550 =
= 7729550 = leak summary:
= 7729550 = definitely lost: 0 bytes in 0 blocks.
==7729550 = possibly lost: 0 bytes in 0 blocks.
= 7729550 = still reachable: 40 bytes in 1 blocks.
= 7729550 = suppressed: 0 bytes in 0 blocks.
= 7729550 = rerun with -- leak-check = Full to see details of leaked memory.

 

I tested it on the production system. The results are good. If you are interested, please pay attention to the compilation and installation process.

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.