You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Charles <fr...@peakpeak.com> on 2002/11/26 20:28:18 UTC

Identifying memory leaks

A Linux machine running Apache/2.0.35 (Unix) mod_perl/1.99_05-dev
Perl/v5.6.1 mysql 4.0.1 uses increasing "used" memory (according
"/usr/bin/free"), eventually resuting in all memory being consumed.  Memory
usage drops somewhat after a reboot of apache and mysql, but not completely.

If a reference does not go out of scope between sessions, that memory will
not be garbage collected.  I would like to test for these types of
difficulties.

Questions:

Are there tools to track total (all threads/processes) mod_perl, apache,
mysql memory usage?

What is the normal behavior for a module which connects (via a global) to a
database in terms of mysql processes started?



Re: Identifying memory leaks

Posted by Stas Bekman <st...@stason.org>.
Charles wrote:
> A Linux machine running Apache/2.0.35 (Unix) mod_perl/1.99_05-dev
> Perl/v5.6.1 mysql 4.0.1 uses increasing "used" memory (according
> "/usr/bin/free"), eventually resuting in all memory being consumed.  Memory
> usage drops somewhat after a reboot of apache and mysql, but not completely.

Well, why it's possible. I doubt it does. Most likely your code causes 
the leakage.

First of all, if you don't report the complete details about your build 
we can't even start helping to you. Use the proper procedure of 
reporting problem as described here:
http://perl.apache.org/docs/2.0/user/help/help.html#Reporting_Problems
(linked from the shortcuts menu on the left of perl.apache.org so it's 
*easy* to find)

Second, do you see the same behavior under mod_perl 1.0?

> If a reference does not go out of scope between sessions, that memory will
> not be garbage collected.  I would like to test for these types of
> difficulties.

First of all you should try and isolate the problem, so your test case 
is simple. Debugging a huge program can be a problem. The mod_perl guide 
discusses several ways to debug problems, though not all tools are 
available to 2.0 yet, so you better off debugging this with mod_perl 1.0 
  if possible. For example see:
http://perl.apache.org/docs/1.0/guide/debug.html#How_can_I_find_out_if_a_mod_perl_code_has_a_memory_leak

> Questions:
> 
> Are there tools to track total (all threads/processes) mod_perl, apache,
> mysql memory usage?

Apache::VMonitor for mod_perl 1.0 should be of a good help. I've several 
obstacles that I'm trying to resolve at the httpd land and then I'll 
make it available for 2.0.

> What is the normal behavior for a module which connects (via a global) to a
> database in terms of mysql processes started?

it's also possible that the way your wrote the code brings huge chunks 
of data from db into the memory and never frees them. (e.g. a closure 
problem 
http://perl.apache.org/docs/general/perl_reference/perl_reference.html).

in summary, narrow down the test case if possible, hopefully without 
involving any rdbms code, send the complete details of your setup and we 
will see what can be done.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com