NAME

Catalyst::Plugin::MemoryUsage - Profile memory usage of requests

VERSION

version 0.0.2

SYNOPSIS

In YourApp.pm:

package YourApp;

use Catalyst qw/
    MemoryUsage
/;

In a Controller class:

sub foo :Path( '/foo' ) {
     # ...
     
     something_big_and_scary();
     
     $c->memory_usage->record( 'finished running iffy code' );
     
     # ...
}

DESCRIPTION

Catalyst::Plugin::MemoryUsage adds a memory usage profile to your debugging log, which looks like this:

[debug] memory usage of request
time    vsz (  diff)    rss (  diff) shared (  diff)   code (  diff)   data (  diff)
    0  45304 ( 45304)  38640 ( 38640)   3448 (  3448)   1112 (  1112)  35168 ( 35168) preparing for the request
    0  45304 (     0)  38640 (     0)   3448 (     0)   1112 (     0)  35168 (     0) after Galuga::Controller::Root : _BEGIN
    0  45304 (     0)  38640 (     0)   3448 (     0)   1112 (     0)  35168 (     0) after Galuga::Controller::Root : _AUTO
    0  46004 (   700)  39268 (   628)   3456 (     8)   1112 (     0)  35868 (   700) finished running iffy code
    0  46004 (     0)  39268 (     0)   3456 (     0)   1112 (     0)  35868 (     0) after Galuga::Controller::Entry : entry/index
    0  46004 (     0)  39268 (     0)   3456 (     0)   1112 (     0)  35868 (     0) after Galuga::Controller::Root : _ACTION
    1  47592 (  1588)  40860 (  1592)   3468 (    12)   1112 (     0)  37456 (  1588) after Galuga::View::Mason : Galuga::View::Mason->process
    1  47592 (     0)  40860 (     0)   3468 (     0)   1112 (     0)  37456 (     0) after Galuga::Controller::Root : end
    1  47592 (     0)  40860 (     0)   3468 (     0)   1112 (     0)  37456 (     0) after Galuga::Controller::Root : _END
    1  47592 (     0)  40860 (     0)   3468 (     0)   1112 (     0)  37456 (     0) after Galuga::Controller::Root : _DISPATCH

METHODS

memory_usage()

Returns the Memory::Usage object available to the context.

To record more measure points for the memory profiling, use the record() method of that object:

sub foo :Path {
    my ( $self, $c) = @_;

    ...

    big_stuff();

    $c->memory_usage->record( "done with big_stuff()" );

    ...
}

reset_memory_usage()

Discards the current Memory::Usage object, along with its recorded data, and replaces it by a shiny new one.

SEE ALSO

Memory::Usage

AUTHOR

Yanick Champoux <yanick@babyl.dyndns.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by Yanick Champoux.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.