[Click] Possible memory leak in Timer code

Roberto Riggio roberto.riggio at create-net.org
Tue Jul 27 03:17:19 EDT 2010


uhm actually no, I was not deleting the timers. Shame on me :(

Thanks Ian

R.

On 07/26/2010 06:01 PM, Ian Rose wrote:
> Perhaps a stupid question but... are you deleting the timers at all?  
> If you continuously create new timer objects and eventually run out of 
> memory, that's not a memory leak, that's just running out of memory.
>
>
> Roberto Riggio wrote:
>> Hi,
>>
>> I'm using a Timer to run a callback function. The timer is created in 
>> the following wayL
>>
>>      Timer *t = new Timer(static_hook, (void *) this);
>>      t->initialize(this);
>>      t->schedule_after_msec(delay);
>>
>> where:
>>
>>      static void static_hook(Timer *, void *e) {
>>          return;
>>      }
>>
>> If I run click using valgrind I get the following output:
>>
>> ==4833== 120 bytes in 5 blocks are definitely lost in loss record 2 of 2
>> ==4833==    at 0x402569A: operator new(unsigned int) 
>> (vg_replace_malloc.c:255)
>> ==4833==    by 0x81DBD96: MyElement::push(int, Packet*) 
>> (myelement.cc:301)
>> ==4833==    by 0x810B329: Element::Port::push(Packet*) const 
>> (element.hh:575)
>> ==4833==    by 0x817E2CD: FromDevice::selected(int, int) 
>> (fromdevice.cc:407)
>> ==4833==    by 0x822B73D: Master::run_selects_poll(RouterThread*, 
>> bool) (master.cc:753)
>> ==4833==    by 0x822B9FA: Master::run_selects(RouterThread*) 
>> (master.cc:1061)
>> ==4833==    by 0x821F95B: RouterThread::driver() (routerthread.cc:431)
>> ==4833==    by 0x81FB925: main (click.cc:598)
>>
>> The line 301 of myelement.cc is the line where the timer is created.
>>
>> The leak do exist in that the system memory is full after the router 
>> is running for
>> a couple of hours. The method is called roughly once every 10 seconds 
>> on a system
>> with 256MB of RAM (an embedded x86 wireless router).
>>
>> R.
>> _______________________________________________
>> click mailing list
>> click at amsterdam.lcs.mit.edu
>> https://amsterdam.lcs.mit.edu/mailman/listinfo/click



More information about the click mailing list