Fixed use GTop
[catagits/Catalyst-Runtime.git] / t / optional / memleak.t
CommitLineData
7c40a30f 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin;
7use lib "$FindBin::Bin/../live/lib";
8
9use Test::More;
10use Catalyst::Test 'TestApp';
11956eee 11eval "use GTop";
7c40a30f 12
13plan skip_all => 'set TEST_MEMLEAK to enable this test'
14 unless $ENV{TEST_MEMLEAK};
15plan skip_all => 'GTop required for this test' if $@;
16
17plan tests => 1;
18
19{
20 # make a request to set initial memory size
21 request('http://localhost');
22
23 my $gtop = GTop->new;
24 my $initial = $gtop->proc_mem($$)->size;
25 print "Initial Size: $initial\n";
26
27 for ( 1 .. 1000 ) {
28 request('http://localhost');
29 }
30
31 my $final = $gtop->proc_mem($$)->size;
32 print "Final Size: $final\n";
33
34 if ( $final > $initial ) {
35 print "Leaked Bytes: " . ( $final - $initial ) . "\n";
36 }
37
38 is( $final, $initial, 'memory is not leaking' );
39}