http://www.perlmonks.org?node_id=911071


in reply to memory usage and leakage

I went further and tried the Net::XMPP code:
#!/usr/bin/perl use strict; use warnings; print_size('empty'); use Net::XMPP; print_size("after Net::XMPP"); for (1..10) { my $conn = Net::XMPP::Client->new; print_size('Net::XMPP::Client created'); my $status = $conn->Connect( hostname => 'talk.google.com', port => 5222, componentname => 'gmail.com', connectiontype => 'tcpip', tls => 1, ); print_size('connection started'); $conn = undef; } sub print_size { my ($msg) = @_; my @lines = qx{/bin/ps -e -o pid,ppid,vsize,rss,command | grep ^$$ +}; chomp @lines; foreach my $line (@lines) { my ($pid, $ppid, $vsize, $rss) = split /\s+/, $line; print "VM: $vsize RSS: $rss - $msg\n"; } return; }
The result is
VM: 48596 RSS: 14648 - empty VM: 48596 RSS: 14652 - after Net::XMPP VM: 48808 RSS: 14744 - Net::XMPP::Client created VM: 67920 RSS: 18344 - connection started VM: 67920 RSS: 18344 - Net::XMPP::Client created VM: 68072 RSS: 18408 - connection started VM: 68072 RSS: 18408 - Net::XMPP::Client created VM: 68192 RSS: 18464 - connection started VM: 68192 RSS: 18464 - Net::XMPP::Client created VM: 68192 RSS: 18516 - connection started VM: 68192 RSS: 18516 - Net::XMPP::Client created VM: 68300 RSS: 18572 - connection started VM: 68300 RSS: 18572 - Net::XMPP::Client created VM: 68412 RSS: 18648 - connection started VM: 68412 RSS: 18648 - Net::XMPP::Client created VM: 68516 RSS: 18712 - connection started VM: 68516 RSS: 18712 - Net::XMPP::Client created VM: 68636 RSS: 18784 - connection started VM: 68636 RSS: 18784 - Net::XMPP::Client created VM: 68740 RSS: 18856 - connection started VM: 68740 RSS: 18856 - Net::XMPP::Client created VM: 68848 RSS: 18928 - connection started
So if I understand correctly this means the Net::XMPP::Client is leaking memory? How could I better check it?