NAME Test::Memory::Usage - make sure code doesn't unexpectedly eat all your memory VERSION version 0.0.3 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 Chisel 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.