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

[Libevent-users] Libevent memory leak?



Hello,

I'm using libevent in some programs and I came across a memory leak in libevent. I'm wondering if I'm the one doing something wrong or it's really something in libevent.

Valgrind reports:

achirila@virtual-machine:~/src/tests$ valgrind --leak-check=full --show-reachable=yes ./test_event.exeÂ
==18888== Memcheck, a memory error detector
==18888== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==18888== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==18888== Command: ./test_event.exe
==18888==Â
==18888==Â
==18888== HEAP SUMMARY:
==18888== Â Â in use at exit: 80 bytes in 2 blocks
==18888== Â total heap usage: 40 allocs, 38 frees, 4,350 bytes allocated
==18888==Â
==18888== 40 bytes in 1 blocks are still reachable in loss record 1 of 2
==18888== Â Âat 0x4C2815C: malloc (vg_replace_malloc.c:236)
==18888== Â Âby 0x4D1759: evthread_posix_lock_alloc (evthread_pthread.c:48)
==18888== Â Âby 0x4C8341: evsig_init (signal.c:174)
==18888== Â Âby 0x4C7AD2: epoll_init (epoll.c:142)
==18888== Â Âby 0x4B9184: event_base_new_with_config (event.c:601)
==18888== Â Âby 0x4B92A4: event_base_new (event.c:439)
==18888== Â Âby 0x404181: main (test_event.c:11)
==18888==Â
==18888== 40 bytes in 1 blocks are still reachable in loss record 2 of 2
==18888== Â Âat 0x4C2815C: malloc (vg_replace_malloc.c:236)
==18888== Â Âby 0x4D1759: evthread_posix_lock_alloc (evthread_pthread.c:48)
==18888== Â Âby 0x4D1361: evutil_secure_rng_init (evutil_rand.c:102)
==18888== Â Âby 0x4D09EE: evdns_base_new (evdns.c:3756)
==18888== Â Âby 0x404196: main (test_event.c:12)
==18888==Â
==18888== LEAK SUMMARY:
==18888== Â Âdefinitely lost: 0 bytes in 0 blocks
==18888== Â Âindirectly lost: 0 bytes in 0 blocks
==18888== Â Â Âpossibly lost: 0 bytes in 0 blocks
==18888== Â Âstill reachable: 80 bytes in 2 blocks
==18888== Â Â Â Â suppressed: 0 bytes in 0 blocks
==18888==Â
==18888== For counts of detected and suppressed errors, rerun with: -v
==18888== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)

Test program:

#include <stdlib.h>
#include <event2/event.h>
#include <event2/dns.h>

int main() {Â
  if(evthread_use_pthreads() < 0) {
    fprintf(stderr, "Could not enable pthreads support in libevent\n");
    exit(1);
  }

  struct event_base *ebp = event_base_new();
  struct evdns_base *dns = evdns_base_new(ebp, 1);
  evdns_base_free(dns, 1);
  event_base_free(ebp);
  return 0;
}

Thank you,
Andrei Chirila

--
Mobile: +49 151 42647382
e-Mail: andreich@xxxxxxxxx