From: Matt S Trout Date: Tue, 6 Dec 2011 22:39:05 +0000 (+0000) Subject: memory leak fixage X-Git-Tag: v0.001002~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1224ea9067b1854ad6b619be0ad20e59d5f7d52d;p=scpubgit%2FTak.git memory leak fixage --- diff --git a/lib/Tak/MetaService.pm b/lib/Tak/MetaService.pm index 203f7af..e80b7c5 100644 --- a/lib/Tak/MetaService.pm +++ b/lib/Tak/MetaService.pm @@ -29,8 +29,13 @@ sub handle_register { if (my ($svc, @rest) = @{$expose->{$name}}) { die "router has no service ${svc}" unless my $service = $router->services->{$svc}; - $args{$name} = Tak::Client->new(service => $service) - ->curry(@rest); + my $client_class = ( + Scalar::Util::isweak($router->services->{$svc}) + ? 'Tak::WeakClient' + : 'Tak::Client' + ); + $args{$name} = $client_class->new(service => $service) + ->curry(@rest); } else { $args{$name} = Tak::WeakClient->new(service => $router); } diff --git a/lib/Tak/ModuleLoader/Hook.pm b/lib/Tak/ModuleLoader/Hook.pm index c1a1627..7d598d3 100644 --- a/lib/Tak/ModuleLoader/Hook.pm +++ b/lib/Tak/ModuleLoader/Hook.pm @@ -2,7 +2,7 @@ package Tak::ModuleLoader::Hook; use Moo; -has sender => (is => 'ro', required => 1); +has sender => (is => 'ro', required => 1, weak_ref => 1); sub Tak::ModuleLoader::Hook::INC { # unqualified INC forced into package main my ($self, $module) = @_;