Changeset 5392


Ignore:
Timestamp:
10/29/09 11:09:03 (2 years ago)
Author:
SvenDowideit
Message:

Item2286: port memory leak changes from rel branch

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/MailerContrib/test/unit/MailerContrib/MailerContribSuite.pm

    r5292 r5392  
    7373    # Must create a new wiki object to force re-registration of users 
    7474    $Foswiki::cfg{EnableEmail} = 1; 
     75        $this->{session}->finish(); 
    7576    $this->{session} = new Foswiki(); 
    7677    $this->{session}->net->setMailHandler( \&FoswikiFnTestCase::sentMail ); 
  • trunk/UnitTestContrib/lib/Unit/TestRunner.pm

    r5145 r5392  
    55use Devel::Symdump; 
    66use Error qw(:try); 
     7#use Devel::Leak::Object qw{ GLOBAL_bless }; 
     8#$Devel::Leak::Object::TRACKSOURCELINES = 1; 
    79 
    810sub new { 
     
    103105            die "Test suite $suite aborted\n" unless $completed; 
    104106        } 
    105     } 
     107   } 
    106108 
    107109    if ( $this->{unexpected_failures} || $this->{unexpected_passes} ) { 
     
    267269    } 
    268270    foreach my $test (@tests) { 
     271                #Devel::Leak::Object::checkpoint(); 
    269272        print "\t$test\n"; 
    270273        $tester->set_up(); 
  • trunk/UnitTestContrib/test/unit/AccessControlTests.pm

    r3745 r5392  
    2020    my $this = shift; 
    2121    $this->SUPER::set_up(); 
    22     $this->{session} = new Foswiki(); 
    2322 
    2423    my $topicObject = Foswiki::Meta->new( 
  • trunk/UnitTestContrib/test/unit/ExceptionTests.pm

    r4645 r5392  
    130130    $this->assert_matches( qr/^the rat$/m,          $output ); 
    131131    $this->assert_matches( qr/^phlegm$/m,           $output ); 
     132     
     133        $session->finish(); 
    132134} 
    133135 
  • trunk/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm

    r5310 r5392  
    21162116    } 
    21172117    $query->path_info("/Current/TestTopic"); 
     2118    $this->{session}->finish() if (defined($this->{session})); 
    21182119    $this->{session} = new Foswiki( undef, $query ); 
    21192120    $Foswiki::Plugins::SESSION = $this->{session}; 
  • trunk/WysiwygPlugin/test/unit/WysiwygPlugin/WysiwygPluginTests.pm

    r4645 r5392  
    9494    $query->method('GET'); 
    9595 
    96     $Foswiki::Plugins::SESSION = new Foswiki( 'guest', $query ); 
     96    $this->{session}->finish(); 
     97    $this->{session} = new Foswiki( 'guest', $query ); 
     98    $Foswiki::Plugins::SESSION = $this->{session}; 
    9799 
    98100    # charset definition affects output, so it is a response method and 
     
    174176    $this->assert( $text eq $out, 
    175177        "'" . anal($out) . "' !=\n'" . anal($text) . "'" ); 
     178    $foswiki->finish(); 
    176179} 
    177180 
     
    226229    $this->assert_str_equals( $text, $out, 
    227230        "'" . anal($out) . "' !=\n'" . anal($text) . "'" ); 
     231    $foswiki->finish(); 
    228232} 
    229233 
  • trunk/core/lib/Foswiki.pm

    r5279 r5392  
    15541554    $query ||= new Foswiki::Request(); 
    15551555    my $this = bless( { sandbox => 'Foswiki::Sandbox' }, $class ); 
     1556 
    15561557    $this->{request}  = $query; 
    15571558    $this->{cgiQuery} = $query;    # for backwards compatibility in contribs 
     
    19081909=begin TML 
    19091910 
     1911---++ ObjectMethod DESTROY() 
     1912 
     1913called by Perl when the Foswiki object goes out of scope 
     1914(maybe should be used kist to ASSERT that finish() was called.. 
     1915 
     1916=cut 
     1917 
     1918#sub DESTROY { 
     1919#    my $this = shift; 
     1920#    $this->finish(); 
     1921#} 
     1922 
     1923=begin TML 
     1924 
    19101925---++ ObjectMethod finish() 
    19111926Break circular references. 
     
    19201935 
    19211936    $_->finish() foreach values %{ $this->{forms} }; 
    1922     $this->{plugins}->finish() if $this->{plugins}; 
     1937    $this->{plugins}->finish()   if $this->{plugins}; 
    19231938    undef $this->{plugins}; 
    1924     $this->{users}->finish() if $this->{users}; 
     1939    $this->{users}->finish()     if $this->{users}; 
    19251940    undef $this->{users}; 
    1926     $this->{prefs}->finish() if $this->{prefs}; 
     1941    $this->{prefs}->finish()     if $this->{prefs}; 
    19271942    undef $this->{prefs}; 
    19281943    $this->{templates}->finish() if $this->{templates}; 
    19291944    undef $this->{templates}; 
    1930     $this->{renderer}->finish() if $this->{renderer}; 
     1945    $this->{renderer}->finish()  if $this->{renderer}; 
    19311946    undef $this->{renderer}; 
    1932     $this->{net}->finish() if $this->{net}; 
     1947    $this->{net}->finish()       if $this->{net}; 
    19331948    undef $this->{net}; 
    1934     $this->{store}->finish() if $this->{store}; 
     1949    $this->{store}->finish()     if $this->{store}; 
    19351950    undef $this->{store}; 
    1936     $this->{search}->finish() if $this->{search}; 
     1951    $this->{search}->finish()    if $this->{search}; 
    19371952    undef $this->{search}; 
    1938     $this->{attach}->finish() if $this->{attach}; 
     1953    $this->{attach}->finish()    if $this->{attach}; 
    19391954    undef $this->{attach}; 
    1940     $this->{security}->finish() if $this->{security}; 
     1955    $this->{security}->finish()  if $this->{security}; 
    19411956    undef $this->{security}; 
    1942     $this->{i18n}->finish() if $this->{i18n}; 
     1957    $this->{i18n}->finish()      if $this->{i18n}; 
    19431958    undef $this->{i18n}; 
    19441959    $this->{cache}->finish() if $this->{cache}; 
    19451960    undef $this->{cache}; 
     1961#TODO: the logger doesn't seem to have a finish... 
     1962#    $this->{logger}->finish()      if $this->{logger}; 
     1963    undef $this->{logger}; 
    19461964 
    19471965    undef $this->{_HTMLHEADERS}; 
  • trunk/core/tools/MemoryCycleTests.pl

    r1065 r5392  
    2121use Devel::Monitor qw(:all); 
    2222 
     23 
    2324BEGIN { 
    24     use File::Spec; 
    25  
    26     unshift @INC, split(/:/, $ENV{FOSWIKI_LIBS} || '../lib' ); 
    27  
    28     # designed to be run within a SVN checkout area 
    29     my @path = split( /\/+/, File::Spec->rel2abs($0) ); 
    30     pop(@path); # the script name 
    31  
    32     while (scalar(@path) > 0) { 
    33         last if -d join( '/', @path).'/twikiplugins/BuildContrib'; 
    34         pop( @path ); 
     25    if ( defined $ENV{GATEWAY_INTERFACE} ) { 
     26        $Foswiki::cfg{Engine} = 'Foswiki::Engine::CGI'; 
     27        use CGI::Carp qw(fatalsToBrowser); 
     28        $SIG{__DIE__} = \&CGI::Carp::confess; 
    3529    } 
    36  
    37     if(scalar(@path)) { 
    38         unshift @INC, join( '/', @path ).'/lib'; 
    39         unshift @INC, join( '/', @path ).'/twikiplugins/BuildContrib/lib'; 
     30    else { 
     31        $Foswiki::cfg{Engine} = 'Foswiki::Engine::CLI'; 
     32        require Carp; 
     33        $SIG{__DIE__} = \&Carp::confess; 
    4034    } 
     35    $ENV{FOSWIKI_ACTION} = 'view'; 
     36    @INC = ('../bin', grep { $_ ne '.' } @INC); 
     37    require 'setlib.cfg'; 
    4138} 
    4239 
     
    4542 
    4643{ 
    47     my $twiki = new Foswiki(); 
    48     $Foswiki::Plugins::SESSION = $twiki; 
    49     monitor('TWiki' => \$Foswiki::Plugins::SESSION ); 
     44    my $session = new Foswiki(); 
     45 
     46    #NOTE that Foswiki::finish() is hiding many circular references by foricbly clearing 
     47    #them with the %$this = (); its worth uncommenting this line once in a while to  
     48    #see if its gettign worse (56 are found as of Jun2006) 
     49    #*Foswiki::finish = sub {}; 
     50 
     51    $Foswiki::Plugins::SESSION = $session; 
     52    monitor('Foswiki' => \$Foswiki::Plugins::SESSION ); 
    5053 
    5154    Foswiki::UI::run( \&Foswiki::UI::View::view ); 
    52      
    53     #NOTE that Foswiki::finish() is hiding many circular references by foricbly clearing 
    54     #them with the %$this = (); its worth commenting out this line once in a while to  
    55     #see if its gettign worse (56 are found as of Jun2006) 
    5655     
    5756    print_circular_ref(\$Foswiki::Plugins::SESSION ); 
  • trunk/core/tools/extender.pl

    r5277 r5392  
    127127    # Can't do this until we have setlib.cfg 
    128128    require Foswiki::Configure::Dependency; 
     129     
     130    $session->finish(); 
     131    undef $session; 
    129132} 
    130133 
Note: See TracChangeset for help on using the changeset viewer.