Skip to content

Commit

Permalink
Item2286: update the memory cycle tests and add memory leak tests
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/branches/Release01x00@5373 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Oct 24, 2009
1 parent 8fae6f1 commit cd96d39
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 21 deletions.
41 changes: 20 additions & 21 deletions core/tools/MemoryCycleTests.pl
Expand Up @@ -20,39 +20,38 @@
use strict;
use Devel::Monitor qw(:all);

BEGIN {
use File::Spec;

unshift @INC, split(/:/, $ENV{FOSWIKI_LIBS} || '../lib' );

# designed to be run within a SVN checkout area
my @path = split( /\/+/, File::Spec->rel2abs($0) );
pop(@path); # the script name

while (scalar(@path) > 0) {
last if -d join( '/', @path).'/twikiplugins/BuildContrib';
pop( @path );
BEGIN {
if ( defined $ENV{GATEWAY_INTERFACE} ) {
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CGI';
use CGI::Carp qw(fatalsToBrowser);
$SIG{__DIE__} = \&CGI::Carp::confess;
}

if(scalar(@path)) {
unshift @INC, join( '/', @path ).'/lib';
unshift @INC, join( '/', @path ).'/twikiplugins/BuildContrib/lib';
else {
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CLI';
require Carp;
$SIG{__DIE__} = \&Carp::confess;
}
$ENV{FOSWIKI_ACTION} = 'view';
@INC = ('../bin', grep { $_ ne '.' } @INC);
require 'setlib.cfg';
}

use Foswiki;
use Foswiki::UI::View;

{
my $twiki = new Foswiki();
$Foswiki::Plugins::SESSION = $twiki;
monitor('TWiki' => \$Foswiki::Plugins::SESSION );
my $session = new Foswiki();

Foswiki::UI::run( \&Foswiki::UI::View::view );

#NOTE that Foswiki::finish() is hiding many circular references by foricbly clearing
#them with the %$this = (); its worth commenting out this line once in a while to
#them with the %$this = (); its worth uncommenting this line once in a while to
#see if its gettign worse (56 are found as of Jun2006)
#*Foswiki::finish = sub {};

$Foswiki::Plugins::SESSION = $session;
monitor('Foswiki' => \$Foswiki::Plugins::SESSION );

Foswiki::UI::run( \&Foswiki::UI::View::view );

print_circular_ref(\$Foswiki::Plugins::SESSION );
}
Expand Down
51 changes: 51 additions & 0 deletions core/tools/MemoryLeakTests.pl
@@ -0,0 +1,51 @@
#!/usr/bin/perl -w
#
# Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2006 SvenDowideit@wikiring.com
# and Foswiki Contributors.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. For
# more details read LICENSE in the root of this distribution.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# As per the GPL, removal of this notice is prohibited.

use strict;
use Devel::Leak::Object qw{ GLOBAL_bless };


BEGIN {
if ( defined $ENV{GATEWAY_INTERFACE} ) {
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CGI';
use CGI::Carp qw(fatalsToBrowser);
$SIG{__DIE__} = \&CGI::Carp::confess;
}
else {
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CLI';
require Carp;
$SIG{__DIE__} = \&Carp::confess;
}
$ENV{FOSWIKI_ACTION} = 'view';
@INC = ('../bin', grep { $_ ne '.' } @INC);
require 'setlib.cfg';
}

use Foswiki;
use Foswiki::UI::View;

{
## $Foswiki::Plugins::SESSION = new Foswiki();
# Foswiki::UI::run( \&Foswiki::UI::View::view );
# $Foswiki::Plugins::SESSION->finish();
# undef $Foswiki::Plugins::SESSION;
$Foswiki::engine->run();
}

1;

0 comments on commit cd96d39

Please sign in to comment.