On Thu Jan 20 20:00:50 2011, agronaught wrote:
Show quoted text> Possibly some progress...
>
> It looks like the Message_free is being called, but (potentially) that
> the memory isn't being deallocated...
>
> I've compiled 0.07 with tracing enabled and the attached test program
> which checks the number of SV's allocated before and after a call.
>
> For example:
>
>
> subtest init => sub {
> my $startcount = Devel::Leak::NoteSV($handle);
>
> my $ctxt = zmq_init();
> ok($ctxt, "zmq_init()");
>
> undef $ctxt;
>
> my $endcount = Devel::Leak::NoteSV($handle);
> is($endcount, $startcount, "SV Leak Check");
> };
>
>
> The undef is to force the cleanup of the variable and the associated
> storage, and then comparing the allocations before and after.
>
> In the above case the output is:
>
> context create context wrapper 4f5ee10 with zmq context 4f5ee30 for
> thread 4bb2010 at rt64944.t line 16.
> ok 1 - zmq_init()
> Context_free for context wrapper 4f5ee10 with zmq context 4f5ee30 for
> thread 4bb2010 at rt64944.t line 21.
>
> so Context_free was called, but the vector wasn't released...
>
> A similar test covers ZeroMQ::Raw::Message using the raw API, after the
> creation and destruction of a single message object we have:
>
> zmq_msg_init_data created message 527bd40 at rt64944.t line 60.
> ok 1 - zmq_msg_init_data()
> Message_free for 527bd40 at rt64944.t line 61.
>
>
> # got: '12467'
> # expected: '12460'
>
> Run the test multiple time...
>
> # got: '12512'
> # expected: '12470'
>
> or Im just outright wrong...
>
> Looking at the code and it is obviously calling zmq_msg_close() and
> Safefree(), so I'm clearely confused...
>
>
#!/usr/bin/perl
use strict;
use Test::More;
use Devel::Leak;
BEGIN {
use_ok 'ZeroMQ::Raw';
use_ok 'ZeroMQ::Constants', qw(:all);
}
my $handle;
subtest init => sub {
my $startcount = Devel::Leak::NoteSV($handle);
my $ctxt = zmq_init();
ok($ctxt, "zmq_init()");
undef $ctxt;
my $endcount = Devel::Leak::NoteSV($handle);
is($endcount, $startcount, "SV Leak Check");
};
subtest socket => sub {
my $startcount = Devel::Leak::NoteSV($handle);
my $ctxt = zmq_init();
ok($ctxt, "zmq_init()");
my $sock = zmq_socket($ctxt, ZMQ_PUB);
ok($sock, "zmq_socket()");
undef $sock;
undef $ctxt;
my $endcount = Devel::Leak::NoteSV($handle);
is($endcount, $startcount, "SV Leak Check");
};
subtest message => sub {
my $startcount = Devel::Leak::NoteSV($handle);
my $msg = zmq_msg_init_data("test");
ok($msg, "zmq_msg_init_data()");
undef $msg;
my $endcount = Devel::Leak::NoteSV($handle);
is($endcount, $startcount, "SV Leak Check");
};
subtest message => sub {
my $startcount = Devel::Leak::NoteSV($handle);
my $msg = zmq_msg_init_data("test");
ok($msg, "zmq_msg_init_data()");
undef $msg;
my $endcount = Devel::Leak::NoteSV($handle);
is($endcount, $startcount, "SV Leak Check");
};
subtest manymessage => sub {
my $startcount = Devel::Leak::NoteSV($handle);
for(0..5) {
my $msg = zmq_msg_init_data("test:$_");
ok($msg, "zmq_msg_init_data()");
}
my $endcount = Devel::Leak::NoteSV($handle);
is($endcount, $startcount, "SV Leak Check");
};
done_testing;