[Catalyst] Finding the memory leaks in a Cat app

Octavian Rasnita orasnita at gmail.com
Mon Aug 16 07:19:40 GMT 2010


Hi Tomas,

From: "Tomas Doran" <bobtfish at bobtfish.net>
> On 13 Aug 2010, at 12:11, Octavian Rasnita wrote:
>> I have a Catalyst application that occupies 180 MB of RAM if it uses  the 
>> internal development server. It occupies more than 1 GB of RAM  if it 
>> uses Apache/mod_perl.
>
> I don't believe that. But never mind..

I have checked the memory by using the top command before and after loading 
the development server and I did it for more times. I've seen that big 
difference so I assume that it is the memory used by my app.

I have moved some modules outside lib because they are used only by some 
scripts which are ran in a cron job, and the memory usage decreased, but it 
is still very high.
Even an empty Cat app started with the development server occupies 36 MB of 
RAM.

It is strange that it occupies so much, because I heard that a Cat app can 
be used even on an VPS with 256 MB RAM. I use Perl 5.10.0 under Ubuntu 
10.04, with the latest Catalyst, latest HTML::FormFu, latest 
Template-Toolkit, latest DBIC and I use Oracle.

>> [debug] Circular reference detected:
>> .------------------------------------------------------------------------.
>> | $ctx->{stash}->{__InstancePerContext_158098900}-
>> >{c}                   |
>> | $ctx->{stash}->{__InstancePerContext_158258668}-
>> >{c}                   |
>> | $ctx->{stash}->{__InstancePerContext_158322332}-
>> >{c}                   |
>> '------------------------------------------------------------------------'
>
> Whatever component in your application is using InstancePerContext is 
> leaking.
>
> Are you using it directly yourself, and if not, what components from  CPAN 
> are you using, at what versions?
>
> (Or, look into a debug dump screen, find the things in the stash which 
> are in an __InstancePerContext key - these are the candidates to blame)
>


Thank you for telling where to find that information. I don't use 
InstancePerContext directly, but C::C::HTML::FormFu uses it.

I have tested an empty Cat app (created with catalyst.pl MyApp) and it was 
not leaking.
I have just changed the controller Root.pm and made it subclass 
C::C::HTML::FormFu instead of C::C and CatalystX::LeakChecker started to 
report leaks and those stash elements were closed to C::C::HTML::FormFu.

So C::C::HTML::FormFu or HTML::FormFu or another module it uses might be the 
leak cause.

I reported this to the HTML::FormFu mailing list.

Thanks.

Octavian

> Cheers
> t0m
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: 
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
> __________ Information from ESET NOD32 Antivirus, version of virus 
> signature database 5363 (20100813) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
> 


__________ Information from ESET NOD32 Antivirus, version of virus signature database 5368 (20100815) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com






More information about the Catalyst mailing list