From: Andy Grundman Date: Wed, 26 Oct 2005 13:49:30 +0000 (+0000) Subject: Added a memory leak test X-Git-Tag: 5.7099_04~1101 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=7c40a30fd6d5c79f408b443002e04fca586c4399 Added a memory leak test --- diff --git a/t/optional/memleak.t b/t/optional/memleak.t new file mode 100644 index 0000000..648cc2c --- /dev/null +++ b/t/optional/memleak.t @@ -0,0 +1,39 @@ +#!perl + +use strict; +use warnings; + +use FindBin; +use lib "$FindBin::Bin/../live/lib"; + +use Test::More; +use Catalyst::Test 'TestApp'; +eval "use GTop2"; + +plan skip_all => 'set TEST_MEMLEAK to enable this test' + unless $ENV{TEST_MEMLEAK}; +plan skip_all => 'GTop required for this test' if $@; + +plan tests => 1; + +{ + # make a request to set initial memory size + request('http://localhost'); + + my $gtop = GTop->new; + my $initial = $gtop->proc_mem($$)->size; + print "Initial Size: $initial\n"; + + for ( 1 .. 1000 ) { + request('http://localhost'); + } + + my $final = $gtop->proc_mem($$)->size; + print "Final Size: $final\n"; + + if ( $final > $initial ) { + print "Leaked Bytes: " . ( $final - $initial ) . "\n"; + } + + is( $final, $initial, 'memory is not leaking' ); +}