You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Miles Crawford <mc...@u.washington.edu> on 2006/11/21 02:05:35 UTC

When is mod_perl in global destruction?

I'm working on the assumption that I would be aided in tracking down memory 
leaks in a large mod_perl application if I could see what objects were having 
their DESTROY method called during global destruction.

This seems to work out well:
sub DESTROY {
     my $self = shift;
     eval { die "Memory leak test"};
     if( $@ =~ /global destruction/ ){
 	CORE::warn("Leaked ". ref($self) ." freed at process destruction!";
     }
}

Except that it destroys whatever is in $@ in legitimate error conditions. 
I've played around with preserving $@ programmtically and using "local $@" but 
these experimentations have convinced me this is a flaky system for 
determining if perl is in it's "global destruction" phase.

Any advice on a more reliable, less side-effect-prone method of doing this 
check?

Thanks,
-Miles