Item9127: CompareRevisionsAddOn should call HTML::Element->delete to avoid memory leaks

pencil
Priority: Normal
Current State: Closed
Released In: 1.0.10
Target Release: patch
Applies To: Extension
Component: CompareRevisionsAddOn
Branches:
Reported By: GilmarSantosJr
Waiting For:
Last Change By: KennethLavrsen
HTML::Element documentation states:

$h->delete()

Detaches this element from its parent (if it has one) and explicitly destroys the element and all its descendants. The return value is undef.

Perl uses garbage collection based on reference counting; when no references to a data structure exist, it's implicitly destroyed -- i.e., when no value anywhere points to a given object anymore, Perl knows it can free up the memory that the now-unused object occupies.

But this fails with HTML::Element trees, because a parent element always holds references to its children, and its children elements hold references to the parent, so no element ever looks like it's not in use. So, to destroy those elements, you need to call $h->delete on the parent.

Foswiki::Contrib::CompareRevisionsAddOn::Compare::compare should call this method to avoid memory leaks. It's not a problem in CGI environment, but users may be using some persistent environment, like FastCGI or mod_perl.

-- GilmarSantosJr - 08 Jun 2010

Since _getTree returns a non-root element, it's needed to navigate to it before calling delete() method.

-- GilmarSantosJr - 08 Jun 2010
 

ItemTemplate edit

Summary CompareRevisionsAddOn should call HTML::Element->delete to avoid memory leaks
ReportedBy GilmarSantosJr
Codebase trunk
SVN Range
AppliesTo Extension
Component CompareRevisionsAddOn
Priority Normal
CurrentState Closed
WaitingFor
Checkins distro:9cb159f7c497
TargetRelease patch
ReleasedIn 1.0.10
Topic revision: r4 - 13 Sep 2010, KennethLavrsen
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy