gurus.
I have a perl script which needs to run in an infinite loop and monitor my gnu/linux’s load average and free ram and send an email using google’s account if the load/ram is above/below the value set.
i found these
How can I find memory leaks in long-running Perl program?
and have done as suggested to use undef but that doesn’t seems to help as most likely I have something that never gets cleared/freed.
here’s a sample of how the memory usage is constantly increasing and after a day it can allocate quite much ram.
Here’s the perl script itself. Can someone point me somewhere on how to fix this. Thanks.
Apart from using cron, there are plenty of system monitoring tools that do all this sort of stuff for you.
Anyway – it’ll be easier to check where memory is being used if you write some subroutines along the lines of:
That will remove a whole bunch of variables from the main body of your script and let you comment out parts of the subroutines to see where memory is used.
Oh – it looks to me as though you are constantly creating $smtp connections even if you aren’t going to send a message. It’d be easier to be sure once you’ve got the main loop smaller by using some subroutines.