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


Reply via email to