I have daemon with children on perl. For daemonize i use Proc::Daemon
. Control daemon and children connected to DB(DBI
lib), childs collect mail via imap (Mail::IMAPClient
lib) too. I undef
all variables in code of children, but over time, a child who works more than anyone, consume a lot of memory. ps
output:
user 16521 0.6 1.6 135560 16516 ? S 10:47 0:54 perl remote_imap.pl
user 16523 0.2 20.0 331976 201764 ? S 10:47 0:21 perl remote_imapd.pl 16521
user 16525 0.1 3.0 157792 30720 ? S 10:47 0:09 perl remote_imapd.pl 16521
user 16527 0.1 3.0 157796 30704 ? S 10:47 0:08 perl remote_imapd.pl 16521
user 16529 0.1 3.0 157796 30572 ? S 10:47 0:09 perl remote_imapd.pl 16521
user 16531 0.1 3.0 157792 30612 ? S 10:47 0:08 perl remote_imapd.pl 16521
for sleep i use usleep
from Time::HiRes
lib. In remote_imap.pl usleep(100000)
, In remote_imapd.pl
- usleep(500000)
.
Why memory is not released, because I did andef
for all variables (except id_connet to DB)? If you want, I'll add code.
Main daemon remote_imap.pl Child remote_imapd.pl