posti has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I'm currently trying to use a Daemon which was originally written for unix.

It seems as if there are several memory leaks in the daemon's source code but I'm unable to detect the objects that are causing them. That's sort of a big issue since the daemon is using more and more memory if running for several hours.

The script I'm talking about is called SpamAssassin, with its Daemon "SpamD". I'm using ActivePerl (5.8.9.827).

I've tried to identify the problem by using the Devel::Leak::Object package, but not really sure how to use it. This is what I got when leaving the script:

Jul 12 12:42:56.660 [1296] info: spamd: server killed by SIGINT, shutt +ing down Tracked objects by class: DB_File::BTREEINFO 2 DB_File::HASHINFO 2 DB_File::RECNOINFO 2 Errno 1 IO::Socket 3 IO::Socket::INET 1 Mail::SpamAssassin 1 Mail::SpamAssassin::Bayes 1 Mail::SpamAssassin::BayesStore::DBM 1 Mail::SpamAssassin::Conf 1 Mail::SpamAssassin::Conf::Parser 1 Mail::SpamAssassin::DnsResolver 1 Mail::SpamAssassin::Locker::Win32 1 Mail::SpamAssassin::Logger::Stderr 1 Mail::SpamAssassin::NetSet 7 Mail::SpamAssassin::Plugin::AutoLearnThreshold 1 Mail::SpamAssassin::Plugin::Bayes 1 Mail::SpamAssassin::Plugin::BodyEval 1 Mail::SpamAssassin::Plugin::Check 1 Mail::SpamAssassin::Plugin::DKIM 1 Mail::SpamAssassin::Plugin::DNSEval 1 Mail::SpamAssassin::Plugin::FreeMail 1 Mail::SpamAssassin::Plugin::HTMLEval 1 Mail::SpamAssassin::Plugin::HTTPSMismatch 1 Mail::SpamAssassin::Plugin::Hashcash 1 Mail::SpamAssassin::Plugin::HeaderEval 1 Mail::SpamAssassin::Plugin::ImageInfo 1 Mail::SpamAssassin::Plugin::MIMEEval 1 Mail::SpamAssassin::Plugin::MIMEHeader 1 Mail::SpamAssassin::Plugin::Pyzor 1 Mail::SpamAssassin::Plugin::Razor2 1 Mail::SpamAssassin::Plugin::RelayEval 1 Mail::SpamAssassin::Plugin::ReplaceTags 1 Mail::SpamAssassin::Plugin::SPF 1 Mail::SpamAssassin::Plugin::SpamCop 1 Mail::SpamAssassin::Plugin::URIDNSBL 1 Mail::SpamAssassin::Plugin::URIDetail 1 Mail::SpamAssassin::Plugin::URIEval 1 Mail::SpamAssassin::Plugin::VBounce 1 Mail::SpamAssassin::Plugin::WLBLEval 1 Mail::SpamAssassin::Plugin::WhiteListSubject 1 Mail::SpamAssassin::PluginHandler 1 Mail::SpamAssassin::SpamdForkScaling 1 Mail::SpamAssassin::SubProcBackChannel 1 Mail::SpamAssassin::Util::TieOneStringHash 1 Math::BigInt 1 Net::DNS::Resolver 1 NetAddr::IP 8 POSIX::SigRt 1 Win32::API 14 Win32::Registry 7


I've already tried to weaken some references, but as I'm still a novice in Perl, it didn't led to a satisfying result.



Any hints on this?

Daniel

Replies are listed 'Best First'.
Re: How to detect and avoid memory leaks on Windows
by bluescreen (Friar) on Jul 12, 2010 at 14:02 UTC

    It is not easy at all to do what you're trying to accomplish, so you might be novice but not coward :D.

    I wouldn't use Devel::Leak::Object at first because you have to provide it with a reference to an object, so you are making assumptions and it can take forever untill you hit the memory leak as spam assassin has thousands lines of code. Here is what I'd do

    • run the SA with a minimal setup (no plugins) that would tell me if the problem is in any plugin or the core itself
    • If there is no memory leak in the core I'd turn on plugins one-by-one (or in groups) untill I find the responsible of the memory leak
    • Once I spot the plugin ( or core module ) I'd read its source code looking for circular references you can use Devel::Leak to help on that
    • last but not least at all, I'd contact the developers of SA and will ask them for help as they might already identify problems in other platforms, don't forget they receive hundres and hundres of reports each day