First, I only have some of the components left as bite size test
scripts, but I have included those below. I will try to recreate more
as I have time, which is none atm.
Now, I have narrowed a couple things down and have an explanation as
to why you don't see the leak.
Here is a break down of my findings so far:
Show quoted text1> 0.29 POE does not have the leak, it also does not try to delete the
serialization package from INC within POE::Filter::Reference.
Show quoted text2> Post version 0.29 POE, the leak only occurs when
POE::Filter::Reference->new() is called.
Show quoted text3> 0.331 POE (the one I was running until today now that 0.34 is
available via ppm) has the leak when using POE::Component::Server::TCP.
Show quoted text4> 0.34 POE no longer leaks when using POE::Component::Server::TCP. I
haven't verified, but my guess is that the filter is created once and
then re-used. I don't know how deep in this fix goes (ie.,
Client::TCP, SocketFactory + Wheels w/filter).
While this means that POE::Component::Server might be ok (now - and
some yet to be determined by me subset of packages), there is the
possibility that people will be bitten by this leak using
POE::Filter::Reference outside of POE::Component::Server::TCP.
It also means that anyone doing something like the following will have
serious problems (which includes me of course...):
POE::Session->create(
inline_states =>
{ _start => sub { &server_start($self,@_); },
server_accepted => sub { &server_accepted($self,@_); },
server_error => sub { &server_error($self,@_); },
client_input => sub { &client_input($self,@_); },
client_error => sub { &client_error($self,@_); },
client_flush => sub { &client_error($self,@_); },
},
);
sub server_start {
my $self = shift;
$_[HEAP]->{server} = POE::Wheel::SocketFactory->new(
BindPort => $self->{port},
SuccessEvent => "server_accepted",
FailureEvent => "server_error",
);
}
sub server_accepted {
my $wheel = POE::Wheel::ReadWrite->new(
Handle => $client_socket,
InputEvent => "client_input",
ErrorEvent => "client_error",
);
$wheel->set_filter( POE::Filter::ReferenceFix->new("YAML") );
}
I have attached two test files, but they are now of limited use since:
Show quoted text1> version 0.34 appears to have done some corrections to the component
server. The only one that should leak now is the client in "filter"
test mode.
Show quoted text2> I don't have a POE kernel version of the client anymore...seems I
accidentaly cleaned it up.
The real question is why is this delete happening anyway and is that
worth anyone using POE::Filter::Reference running the risk of memory
leaking?
It isn't exactly helping with cleanup, it slows down the filter by
forcing a reload of the package, and then challenging the universe to
break something because your re-BEGINing a module (which, at a minimum
is causing warnings to spew out on packages like YAML).
Why is the the delete from INC there?
On Sat Apr 29 20:36:09 2006, RCAPUTO wrote:
Show quoted text> Could you send your test case? It's sufficiently different from the
> cookbook recipe that I can't re-create it myself. Not for trying,
but
Show quoted text> my tries don't leak the way yours does.
>
> On Sat Apr 29 20:32:40 2006, allend@Zoo.org wrote:
> > After much hair loss, I have narrowed down one of several POE
related
Show quoted text> > memory leaks in a project I am working on (on both AS Win32 and
linux
Show quoted text> > perls, 5.8.x):
> >
> > POE::Filter::Reference
> >
> > The culprit code seems to be:
> >
> > delete $INC{$package . ".pm"};
> >
> > eval {
> > local $^W=0;
> > require "$package.pm";
> > import $freezer ();
> > };
> > carp $@ if $@;
> >
> > Simply commenting out the delete line removed a very serious leak
> > using POE::Wheel::SocketFactory + POE::Wheel::ReadWrite + filter.
> >
> > To note, I had also tested the cookbook code @
http://poe.perl.org/?
Show quoted text> > POE_Cookbook/Application_Servers (slightly altered to use YAML,
to
Show quoted text> > keep socket open and listen to a stress test version of the
client
Show quoted text> > that kept calling into the server), which also demonstrated the
leak
Show quoted text> > (both client and server).
> >
> > A non-POE YAML client, however didn't demonstrate the leak. So
then
Show quoted text> > I tried storable, which also leaked in all but a non-POE version
of
Show quoted text> > the client.
> >
> > So I started to look into this package, and hand calling
> > POE::Filter::Reference outside of any POE framework showed that
the
Show quoted text> > leak was indeed in the new() method.
> >
> > I can't think of many serious problems with this change...anyone
else
Show quoted text> > have a thought on what badness removing the delete could cause.
> >
> > Still some testing to do, but so far my code and the cookbook
based
Show quoted text> > version appear to be much much happier.
> >
> >
>
>