Thread: Is dlopen leaking memory?

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    66

    Is dlopen leaking memory?

    Hi.

    I have the following code:

    Code:
    char file_path[256];
    ...
    handle = dlopen(file_path, RTLD_LAZY);
    ...
    dlclose(handle);
    This part was working just fine. If I ran my application through valgrind, it said that all blocks were freed, and no leaks are possibile, but today when I tried to do the same thing I got the following report:


    ==12394== 20 bytes in 1 blocks are still reachable in loss record 1 of 1
    ==12394== at 0x40053B3: calloc (vg_replace_malloc.c:467)
    ==12394== by 0x5860A5: _dlerror_run (dlerror.c:142)
    ==12394== by 0x585B70: dlopen@@GLIBC_2.1 (dlopen.c:88)

    and at the end:


    ==12394== LEAK SUMMARY:
    ==12394== definitely lost: 0 bytes in 0 blocks
    ==12394== indirectly lost: 0 bytes in 0 blocks
    ==12394== possibly lost: 0 bytes in 0 blocks
    ==12394== still reachable: 20 bytes in 1 blocks
    ==12394== suppressed: 0 bytes in 0 blocks

    It is true that I made some changes to the source code, but not to this part, and even if I remove them, still get the same report.

    I looked around on google, and saw, that some other people had the same problem, but I didn`t find a solution anywhere.

    Is it possible that dlopen is in fact leaking memory, or maybe there is a bug in valgrind?

    My OS is CentOS 6 with kernel version 2.6.32-279.5.2.el6.i686.


    Thank you.

    P.S. The last update I made on my computer contains a kernel-devel update, but it`s hard to believe that it is because of this.

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    It means that your program is "probably okay". It doesn't actually have to release memory just because it could have. See Valgrind
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gmp/pthread program leaking memory. Why?
    By sadakatsu in forum C Programming
    Replies: 5
    Last Post: 03-01-2012, 08:34 PM
  2. Is my SDL program leaking memory?
    By LyTning94 in forum C++ Programming
    Replies: 6
    Last Post: 07-19-2011, 01:18 PM
  3. Leaking memory when creating threads
    By Elkvis in forum Windows Programming
    Replies: 3
    Last Post: 08-18-2009, 02:27 PM
  4. Leaking Memory in a sendmail milter I wrote?
    By stevfletchcom in forum C Programming
    Replies: 8
    Last Post: 10-10-2008, 11:30 AM
  5. traping leaking memory
    By null in forum C Programming
    Replies: 5
    Last Post: 10-01-2001, 12:02 PM