Problems? Is your data what you think it is? | |
PerlMonks |
Memory usage of a "sub" in mod_perlby diego_de_lima (Beadle) |
on May 23, 2008 at 12:55 UTC ( [id://688132]=perlquestion: print w/replies, xml ) | Need Help?? |
diego_de_lima has asked for the wisdom of the Perl Monks concerning the following question:
Hello fellow monks! Now that my mod_perl processes are gowing to more than 60mb each, Iīm trying to clean up averything I can. Well, it used to be 100mb each, and by eliminating some unused modules I could reduce ir drastically. But now Iīm stucked in the problem of the process memory usage growing big during its lifetime. I have no public variables, and everything is OO. There is some packages which recieves big HTML strings which are latter printed to the browser. Sometimes I can have a 1mb HTML output or even more. This packages are destroyed by the end of the session, wich is handled by a mod_perl handler (not a cgi file). Iīm doing something like: sub handler { my $r = shift; my $page = new Html::page; $page->{html} = '...and here it goes...'; $page->end(); # Does some final processing print "Content-type:...". $page->{html}; undef $page; }This "end" sub is very simple, and looks like: sub end { my $class = shift; $class->{html} = "Header" . $class->{html} . "Footer"; }Apache2::Satus says itīs consumes about 27kb before serving a request. But, after being executed, it grows to the size of the HTML it processed (109kb in the example below). BEFORE serving a request I get: Memory Usage for package Html::page Totals: 68703 bytes, 67.09 Kb, 0.07 Mb | 1284 OPs end 27748 bytes | 573 OPs new 7045 bytes | 146 OPsAnd AFTER serving a request I get: Memory Usage for package Html::page Totals: 151779 bytes, 148.22 Kb, 0.15 Mb | 1284 OPs end 109244 bytes | 573 OPs new 7045 bytes | 146 OPsObviously the mod_perl process grows in the same rate, and it never releases memory. So I end up sometimes with process that grows from 62mb to 120mb in just one request. Am I doing something wrong? Acording to my knowledge, Perl should release the memory used in the $page->{html} variable just after I undef $page or simply do $page->{html} = ''; Or maybe Iīm wrong? By the way: Linux Fedora 6 with Perl 5.8.8, Apache 2.2.3, mod_perl 2.0.2. Thanks a lot for your attention monks! Deigo de Lima
Back to
Seekers of Perl Wisdom
|
|