[Catalyst] Finding the memory leaks in a Cat app
Octavian Rasnita
octavian.rasnita at ssifbroker.ro
Fri Aug 13 11:11:28 GMT 2010
Hello,
I have a Catalyst application that occupies 180 MB of RAM if it uses the in=
ternal development server. It occupies more than 1 GB of RAM if it uses Apa=
che/mod_perl.
Even though it is very much, it would be OK if the memory usage wouldn't in=
crease on each request.
I have started Apache with the -X parameter to use a single process and I h=
ave also changed to "1" all the settings for Prefork MPM, but when using th=
e ab utility, the memory usage increases and it creates swap.
The memory it occupies also increases if I use the internal development ser=
ver.
So I am pretty sure my app has some memory leaks and I tried to use Catalys=
tX::LeakChecker for finding them.
It gave the following results, but I don't know how to interpret them and f=
ind the piece of code that create leaks:
[debug] Circular reference detected:
.------------------------------------------------------------------------.
| $ctx->{stash}->{__InstancePerContext_158098900}->{c} |
| $ctx->{stash}->{__InstancePerContext_158258668}->{c} |
| $ctx->{stash}->{__InstancePerContext_158322332}->{c} |
'------------------------------------------------------------------------'
I've also tried to use C::P::LeakTracker by adding it to the list of plugin=
s and creating the Leaks.pm controller:
package BRK::Controller::Leaks;
use Moose;
use namespace::autoclean;
use parent qw(Catalyst::Controller::LeakTracker);
sub index :Path :Args(0) {
my ( $self, $c ) =3D @_;
$c->forward("list_requests"); # redirect to request listing view
}
__PACKAGE__->meta->make_immutable;
1;
But when I access it, it gives the error below.
Please give me some hints for using these 2 modules, or recommend another w=
ay of finding the code that create memory leaks.
Thank you.
I am using Perl 5.10.1 and Catalyst 5.80025.
Here is the error generated when I access /leaks:
Couldn't load class (MyApp) because: Couldn't instantiate component "MyApp:=
:Controller::Leaks", "Inconsistent hierarchy during C3 merge of class 'MyAp=
p::Controller::Leaks': merging failed on parent 'Moose::Object' at e:/usr/l=
ib/mro.pm line 24."Compilation failed in require at e:/usr/site/lib/Class/M=
OP.pm line 114.
at e:/usr/site/lib/Class/MOP.pm line 120
Class::MOP::__ANON__('Couldn\'t instantiate component "MyApp::Controller::=
Leaks", "In...') called at e:/usr/site/lib/Try/Tiny.pm line 98
Try::Tiny::try('CODE(0x2062e54)', 'Try::Tiny::Catch=3DREF(0x2ae97d4)') cal=
led at e:/usr/site/lib/Class/MOP.pm line 125
Class::MOP::load_first_existing_class('MyApp') called at e:/usr/site/lib/C=
lass/MOP.pm line 137
Class::MOP::load_class('MyApp') called at e:/usr/site/lib/Catalyst/ScriptR=
ole.pm line 61
Catalyst::ScriptRole::_run_application('Catalyst::Script::Server=3DHASH(0x=
2b16f9c)') called at e:/usr/site/lib/Catalyst/Script/Server.pm line 181
Catalyst::Script::Server::run('Catalyst::Script::Server=3DHASH(0x2b16f9c)'=
) called at e:/usr/site/lib/Class/MOP/Method/Wrapped.pm line 48
Class::MOP::Method::Wrapped::__ANON__('Catalyst::Script::Server=3DHASH(0x2=
b16f9c)') called at e:/usr/site/lib/Class/MOP/Method/Wrapped.pm line 89
Catalyst::Script::Server::run('Catalyst::Script::Server=3DHASH(0x2b16f9c)'=
) called at e:/usr/site/lib/Catalyst/ScriptRunner.pm line 20
Catalyst::ScriptRunner::run('Catalyst::ScriptRunner', 'MyApp', 'Server') c=
alled at script/myapp_server.pl line 8
--
Octavian
__________ Information from ESET NOD32 Antivirus, version of virus signatur=
e database 5363 (20100813) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100813/afb7c=
398/attachment.htm
More information about the Catalyst
mailing list