NAME
    Test::Memory::Usage - make sure code doesn't unexpectedly eat all your
    memory

VERSION
    version 0.0.5

SYNOPSIS
    The easiest usage pattern looks like this:

        use Test::Memory::Usage;

        # do some setup; decide that's roughly where you should be with usage
        # levels; draw your lin in the sand
        memory_usage_start;

        # do some things that you want to test as normal
        # ...
    
        # finally, make sure you haven't run away with memory
        memory_usage_ok;
        done_testing;

    You can call "memory_usage_start" as often as you like; each call moves
    the reference point used for comparison with "memory_usage_ok":

        # loop over some action and make sure it doesn't grow
        for (1 .. 5) {
            memory_usage_start;

            # bad growing code!
    
            memory_usage_ok(10);
        }

EXPORTS
    Test::Memory::Usage exports the following subs automatically:

    memory_usage_start
    memory_usage_ok
    memory_virtual_ok
    memory_rss_ok
    memory_stack_ok

METHODS
    The module provides the following methods:

  memory_usage_start
    This method records the current memory usage and flags it to be used for
    any growth tests later in the script.

    You can call the method multiple times; each call adds a new state
    record and updates makes the most recent state recorded the reference
    point for any growth comparisons

    This is useful if you want to compare the usage after you've performed a
    certain amount of minimum setup before the area(s) of code that you want
    to verify memory usage for.

  memory_usage_ok($percentage_limit)
    This calls the "memory_virtual_ok()" and "memory_rss_ok()" functions.

    If not provided $percentage_limit defaults to '10'.

  memory_virtual_ok($percentage_limit)
    Runs the test to ensure that virtual memory usage hasn't grown more than
    $percentage_limit

    This isn't usually called explicitly as most users will find
    "memory_usage_ok()" meets their testing needs.

    If not provided $percentage_limit defaults to '10'.

  memory_rss_ok($percentage_limit)
    Runs the test to ensure that RSS memory usage hasn't grown more than
    $percentage_limit

    This isn't usually called explicitly as most users will find
    "memory_usage_ok()" meets their testing needs.

    If not provided $percentage_limit defaults to '10'.

  memory_stack_ok($percentage_limit)
    Runs the test to ensure that data/stack memory usage hasn't grown more
    than $percentage_limit

    This isn't usually called explicitly as most users will find
    "memory_usage_ok()" meets their testing needs.

    If not provided $percentage_limit defaults to '10'.

SEE ALSO
    Memory::Usage

AUTHOR'S NOTES
    I still have some concerns over the benefit of this module for testing.

    While it behaved fairly well locally, the test reports for failures from
    cpantesters.org <http://cpantesters.org/distro/T/Test-Memory-Usage.html>
    demonstrated that either the approach is flawed in general, or that I'm
    just bad at writing portable tests.

    The module was briefly removed from the CPAN because I doubted the
    usefulness of this module and didn't want to muddy the waters with a
    potentially frustrating test module.

    It can sometimes be tricky to determine the right level of growth, if
    any, that you'll allow your process to have. Maybe my flaw was just that
    I set them all to be too strict.

    After receiving a tweet recently I decided to re-upload this module, and
    allow people to make their own choice.

    Any improvements to the module, or the test suite would be greatly
    appreciated. I wrote this module to attempt to prevent horrific memory
    leaks in some code I was maintaining, so this or something like this
    could be beneficial.

    Chisel, May 2013

AUTHOR
    Chisel <chisel@chizography.net>

COPYRIGHT AND LICENSE
    This software is copyright (c) 2011 by Chisel Wright.

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

