Руслан У. Закиров > MasonX-LeakGuard-Object-0.03 > MasonX::LeakGuard::Object



Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  


MasonX::LeakGuard::Object - report memory leaks (objects) per request


    use MasonX::LeakGuard::Object;
    %MasonX::LeakGuard::Object::OPTIONS = (
        exclude => [
        hide_arguments => [
            'pass', 'password',
    my @MasonParameters = (
        plugins => [qw(MasonX::LeakGuard::Object)],


This is plugin for HTML::Mason based applications that helps you find memory leaks in OO code. It uses Devel::LeakGuard::Object framework for that.


It's possible to use all options leakguard function in Devel::LeakGuard::Object supports. Look at "SYNOPSIS" for example.

Some additional options are supported.


on_leak option can be used to customize report or redirect to custom log, for example:

    %MasonX::LeakGuard::Object::OPTIONS = (
        on_leak => sub {
            my ($report, %args) = @_;
            MyApp->logger->error( $args{'message'} );

First argument is the report structure (read more on it in Devel::LeakGuard::Object). To make life easier more data is passed into your function as a hash. The hash contains:

formatted - formatted report, a text table.
message - formatted default message containg description, request path, request arguments and report. For example:
    Leak(s) found after request to '/index.html' with $ARGS1 = [
    Leaked objects:
      Class          Before  After  Delta
      MyApp::Class        0      1      1
path - request path.
arguments - request arguments, array reference.


It's possible to specify list of arguments names to hide from reports, for example:

    %MasonX::LeakGuard::Object::OPTIONS = (
        hide_arguments => [
            'pass', 'password',


It's possible that false positives are reported, for example if a compontent has ONCE block where you cache some values on first request. Most caches will generate false positive reports, but it's possible to use options of function leakguard in Devel::LeakGuard::Object. Look at "SYNOPSIS" for example and "OPTIONS" for additional details.

To avoid many false positives the module as well ignores first request to a path.

Sure it doesn't protect you from all cases.


Ruslan Zakirov <>


Under the same terms as perl itself.


syntax highlighting: