Skip to content

Commit

Permalink
Item14329: Resolve some possible memory leaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
gac410 committed Mar 28, 2017
1 parent c8341b8 commit 38650f9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions core/lib/Foswiki.pm
Expand Up @@ -2375,13 +2375,19 @@ sub finish {
undef $this->{requestedWebName}; # Web name before renaming
undef $this->{scriptUrlPath};
undef $this->{user};
$this->{users}->finish() if $this->{users};
undef $this->{users};
undef $this->{_INCLUDES};
undef $this->{response};
undef $this->{evaluating_if};
undef $this->{_addedToHEAD};
undef $this->{sandbox};
undef $this->{evaluatingEval};
undef $this->{_ffCache};
$this->{zones}->finish() if $this->{zones};
undef $this->{zones};
$this->{renderer}->finish() if $this->{renderer};
undef $this->{renderer};

undef $this->{DebugVerificationCode}; # from Foswiki::UI::Register
if (SINGLE_SINGLETONS_TRACE) {
Expand Down
7 changes: 7 additions & 0 deletions core/lib/Foswiki/Meta.pm
Expand Up @@ -534,6 +534,13 @@ sub finish {
undef $this->{_web};
undef $this->{_topic};
undef $this->{_session};
undef $this->{_loadedRev};
undef $this->{_latestIsLoaded};
undef $this->{_text};
undef $this->{_preferences};
undef $this->{_indices};
undef $this->{FILEATTACHMENT};

if (DEBUG) {

#someone keeps adding random references to Meta so to shake them out..
Expand Down
5 changes: 4 additions & 1 deletion core/lib/Foswiki/MetaCache.pm
Expand Up @@ -76,20 +76,23 @@ Break circular references.

sub finish {
my $this = shift;
undef $this->{session};

#must clear cache every request until the cache is hooked up to Store's save
foreach my $cuid ( keys( %{ $this->{cache} } ) ) {
foreach my $web ( keys( %{ $this->{cache}->{$cuid} } ) ) {
foreach my $topic ( keys( %{ $this->{cache}->{$cuid}->{$web} } ) ) {
$this->{cache}->{$cuid}{$web}{$topic}{tom}->finish();
undef $this->{cache}->{$cuid}{$web}{$topic};
$this->{undef_count}++;
}
undef $this->{cache}->{$cuid}{$web};
}
undef $this->{cache}->{$cuid};
}

undef $this->{session};
undef $this->{cache};
undef $this->{meta_cache_session_user};

if (TRACE) {
print STDERR
Expand Down
1 change: 1 addition & 0 deletions core/lib/Foswiki/Render.pm
Expand Up @@ -105,6 +105,7 @@ Break circular references.
# documentation" of the live fields in the object.
sub finish {
my $this = shift;
undef $this->{_anchorNames};
undef $this->{NEWLINKFORMAT};
undef $this->{LINKTOOLTIPINFO};
undef $this->{LIST};
Expand Down
4 changes: 3 additions & 1 deletion core/lib/Foswiki/Render/Zones.pm
Expand Up @@ -174,7 +174,9 @@ sub _renderZoneById {
my $zone = $params->{_DEFAULT} || $params->{zone};

#return "\n<!--ZONE $id-->\n" . _renderZone( $this, $zone, $params, $topicObject ) . "\n<!--ENDZONE $id-->\n" ;
return _renderZone( $this, $zone, $params, $topicObject );
my $result = _renderZone( $this, $zone, $params, $topicObject );
$this->{_renderZonePlaceholder}{$id} = undef;
return $result;
}

# This private function is used in ZoneTests
Expand Down
2 changes: 2 additions & 0 deletions core/tools/MemoryCycleTests.pl
Expand Up @@ -52,6 +52,8 @@ BEGIN

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

#$Foswiki::engine->run();

print_circular_ref( \$Foswiki::Plugins::SESSION );
}

Expand Down

0 comments on commit 38650f9

Please sign in to comment.