Skip to content

Commit

Permalink
Item13897: Fixed few memory leaks.
Browse files Browse the repository at this point in the history
Generally saying, all memory leaks I currently observe on a test load of
a single PerDoc topic of Foswiki::Exception documentation are related to
use of global variables.

Imported Devel::Leak::Object module and adapted it to support
Foswiki::Object infrastructure to get correct locations of where objects
were created and to keep stacktraces for easy tracking down of leakage
causes. Because it's primarily a test-related module included it into
UnitTestContrib unfrastructure and called it Unit::Leak::Object.

- foswiki_debug.psgi tries to make use of Unit::Leak::Object first and
then falls back to Devel::Leak::Object if failed.

- QUERY macro object is now using attribute evalParser instead of a
global variable $evalParser.

- Got rid of BEGIN block in Query::Node.

- Added method __orig to Foswiki::Object which locates the exact point
where object was created bypassing ::new and ::create methods.

- JsonRpcContrib cleans up $SERVER global variable upon destruction.
  • Loading branch information
vrurg committed Sep 24, 2016
1 parent a517114 commit fbf6a84
Show file tree
Hide file tree
Showing 12 changed files with 519 additions and 43 deletions.
8 changes: 5 additions & 3 deletions JsonRpcContrib/lib/Foswiki/Contrib/JsonRpcContrib.pm
@@ -1,13 +1,11 @@
# See bottom of file for license and copyright information

package Foswiki::Contrib::JsonRpcContrib;
use v5.14;

use Foswiki::Request ();
use Foswiki::Contrib::JsonRpcContrib::Server ();

use Moo;
use namespace::clean;
use Foswiki::Class;
extends qw(Foswiki::UI);

#BEGIN {
Expand Down Expand Up @@ -50,6 +48,10 @@ sub BUILD {
$SERVER = $this->server;
}

sub DEMOLISH {
undef $SERVER;
}

sub registerMethod {
$Foswiki::app->create(__PACKAGE__) unless $SERVER;
$SERVER->registerMethod(@_);
Expand Down
Expand Up @@ -14,6 +14,7 @@ lib/Unit/CGIEngine.pm 0644
lib/Unit/Eavesdrop.pm 0644
lib/Unit/ExternalEngine.pm 0644
lib/Unit/HTMLDiffer.pm 0644
lib/Unit/Leak/Object.pm 0644
lib/Unit/Response.pm 0644
lib/Unit/TestCase.pm 0644
lib/Unit/PlackTestCase.pm 0644
Expand Down

0 comments on commit fbf6a84

Please sign in to comment.