in reply to Event.pm memory leek ?

No, this is a memory leak in your code.

Don't put memory allocation in a signal handler. The underpinnings of printf are mallocing. Before printf can free, you are calling the signal handler again.

Replies are listed 'Best First'.
Re^2: Event.pm memory leek ?
by asdfgroup (Beadle) on Apr 22, 2005 at 19:02 UTC
    This does not look correct, because :
    - signal is masked in own callback (normal Unix behaviour, tested this is ok in Event.pm as well)
    - if you change printf on print or even syswrite, memory leak will still exist
    - similar code works fine in test without Event.pm (using %SIG)

    Update: code like
    use Event; Event->signal(signal=>'HUP', cb=>sub {kill 1, $$}); kill 1, $$; Event::loop;
    produce memory leak as well :)
      Ok, so not only does your code malloc inside a signal handler, so does Event.

      Well, Event.xs shows that when signal is called, it does copying.

      _signal_signal(THIS, items == 2? sv_mortalcopy(ST(1)) : 0);
      sv_mortalcopy mallocs. Since you are calling the signal handler from inside the signal handler, it never frees that memory. Simple solution: Don't call the signal handler from inside the signal handler.