Update (Aug 02):I've edited my original post to include downloadable code and clarify the test case.
I have a Catalyst applications, which uses Catalyst::Model::KiokuDB (v0.12) with the CouchDB-backend. The applications leaks slightly for every request that access (not even use) the model. The controller (listed below) I'm using for reproducing this problem is simply calling $context->model() and then returns an empty reply, without ever using the model.
I've tracked it down to something related to Catalyst::Model::KiokuDB::save_scope(). Commenting out the call to save_scope() in ACCEPT_CONTEXT() removes the leak completely.
I've tried every single object and memory debug tool I know of, without any luck:
So now I have two questions for the collective wisdom of the PerlMonks:
package TestApp::Controller::Leaktest; use strict; use warnings; use Moose; use utf8; use namespace::autoclean; BEGIN { extends 'Catalyst::Controller' } sub index :Path :Args(0) { my ($self, $context) = @_; my $model = $context->model(); $c->response->body(""); $c->response->status(400); 1; } sub modules :Local { my( $self, $c, @path ) = @_; { no strict; # We're accessing $VERSION by symbolic reference no warnings 'uninitialized'; # The $VERSION might not be defin +ed $c->response->body(join "\n", map { s!/!::!g; # We're getting a file name.. +. s!.pm$!!; # ...and want a module name sprintf "%-80s %s", $_, ${"${_}::VERSIO +N"} } sort keys %INC); } $c->response->content_type("text/plain"); $c->stash->{current_view} = 'Nop'; 1; } sub exit :Local :Args(0) { exit(0); } 1;
package TestApp::Model::KiokuDB; use Moose; BEGIN { extends 'Catalyst::Model::KiokuDB'; } __PACKAGE__->config( model_class => 'KiokuX::Model', model_args => { dsn => 'couchdb::uri=http://127.0.0.1:5984/lb-local', } ); 1;
#!/bin/bash URL="http://localhost:3000/leaktest" EXIT="http://localhost:3000/leaktest/exit" APPNAME="testapp_server.pl" PID=$(pgrep -f ${APPNAME}) if [[ -z $PID ]]; then echo "Please start ${APPNAME} first!" exit 1; fi echo -e "HITS\tSZ\tRSS" echo -ne "0\t" ps -p ${PID} -o size,rss | sed -ne '2s/[ ]\+/\t/gp' for OUTER in $(seq 1 10); do for INNER in $(seq 1 1000); do ( curl $URL 2>&1) > /dev/null done echo -ne "$((${OUTER} * 1000))\t" ps -p ${PID} -o size,rss | sed -ne '2s/[ ]\+/\t/gp' done ( curl ${EXIT} 2>&1) > /dev/null
The following list was obtained from TestApp with
# curl -s http://localhost:3000/leaktest/modules | sed -ne '/.*\(Catalyst\|KiokuDB\).*[0-9\.]\+/p':
I'll be happy to provide more details, but I was reluctant with posting the complete 449 lines long list.Catalyst + 5.80032 Catalyst::Action + -1, set by base.pm Catalyst::Action::RenderView + 0.16 Catalyst::Devel + 1.31 Catalyst::Model::KiokuDB + 0.12 Catalyst::Plugin::ConfigLoader + 0.30 Catalyst::Plugin::Static::Simple + 0.29 Catalyst::Runtime + 5.80032 KiokuDB + 0.52 KiokuDB::Backend::CouchDB + 0.10
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |