libgtop: Suspicious memory leak.



Hello,
 
I have the fllowing prog which leaks. I removed all the irrelevant parts.
Different functions call lead to memory leaks :
 
#include <stdlib.h>
#include <stdio.h>
#include <libgtop-2.0/glibtop.h>
#include <libgtop-2.0/glibtop/netload.h>
#include <libgtop-2.0/glibtop/close.h>
 
int main(int argc, char ** argv){
 
    glibtop_init();
    /* GET NET USAGE */
    glibtop_netload buf;
    const char interface[] = "wlan0";
 
    glibtop_get_netload(&buf, interface);
 
    printf("NETWORK :%lu %lu\n", buf.packets_in, buf.packets_out);
 
    // Just in case
    g_free(&buf);
    glibtop_close();
    return 0;
}
 
and valgrind reports:
 
==23998== Memcheck, a memory error detector
==23998== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==23998== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==23998== Command: ./a.out
==23998== 
glibtop: Non-standard uts for running kernel:
release 3.11-2-amd64=3.11.0 gives version code 199424
 
NETWORK :133204 104140
==23998== 
==23998== HEAP SUMMARY:
==23998==     in use at exit: 49 bytes in 2 blocks
==23998==   total heap usage: 8 allocs, 6 frees, 5,313 bytes allocated
==23998== 
==23998== 13 bytes in 1 blocks are still reachable in loss record 1 of 2
==23998==    at 0x4C2935B: malloc (vg_replace_malloc.c:270)
==23998==    by 0x4E80940: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3600.4)
==23998==    by 0x4E97BEE: g_strdup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3600.4)
==23998==    by 0x51366F3: glibtop_init_r (in /usr/lib/libgtop-2.0.so.7.2.0)
==23998==    by 0x40067B: main (in /home/me/a.out)
==23998== 
==23998== 36 bytes in 1 blocks are still reachable in loss record 2 of 2
==23998==    at 0x4C2935B: malloc (vg_replace_malloc.c:270)
==23998==    by 0x4E80940: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3600.4)
==23998==    by 0x4E97BEE: g_strdup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3600.4)
==23998==    by 0x513672B: glibtop_init_r (in /usr/lib/libgtop-2.0.so.7.2.0)
==23998==    by 0x40067B: main (in in /home/me/a.out)
==23998== 
==23998== LEAK SUMMARY:
==23998==    definitely lost: 0 bytes in 0 blocks
==23998==    indirectly lost: 0 bytes in 0 blocks
==23998==      possibly lost: 0 bytes in 0 blocks
==23998==    still reachable: 49 bytes in 2 blocks
==23998==         suppressed: 0 bytes in 0 blocks
==23998== 
==23998== For counts of detected and suppressed errors, rerun with: -v
==23998== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
 
I posted in the gtk-list but I think it is better here.

Anyone here to help please ?

Thanks
                                                                                  


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]