Subject: | Memory leak |
Date: | Thu, 7 May 2015 14:19:52 +0200 |
To: | bug-Net-NfDump [...] rt.cpan.org |
From: | DULAUNOY Fabrice <fabrice [...] dulaunoy.com> |
Hi All,
I would like to report a small trouble with the module Net::NfDump.
I did the test with Net::NfDump 1.07 and nfdump 1.62 and 1.63 (CentOS 6, CentOS 7, Debian SID)
A memory leak occur in the module ( or maybe in the XS part ) when the query method is called.
Here is the test to display the trouble:
#!/usr/bin/perl
use strict;
use warnings;
use Net::NfDump;
open PID,'>', '/tmp/net-nfdump-mem.pid';
print PID "$$\n";
close PID;
my $file = shift;
while ( 1 )
{
my $flow = new Net::NfDump(
InputFiles => $file,
Fields => [qw(srcip dstip)],
);
$flow->query();
$flow->finish();
sleep 1;
}
I saved this code in the file net-nfdump-leak.pl
Use like this:
perl net-nfdump-leak.pl /a/nfcapd/file
Follow the memory usage with:
while [ 1 ] ; do ps h -o pid,rss,vsz,size -p $(cat /tmp/net-nfdump-mem.pid) ; sleep 4 ; done
You could see the memory usage continuously increasing.
The memory increase is not related to nfcapd file the size (same result with small or big file)nor with the number of Fields in use (2 like in that sample or 24 like in my real case)
I would like to use the module in a long running daemon.
For now I did a fork of the nfdump processing to avoid memory exhaustion, but this is not optimal.
Best regards and thanks for your module.
DULAUNOY Fabrice