Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I track down a mod_perl memory leak?

I'm using mod perl 1.3.0 with apache 1.3.41 perl version 5.8.6, and the memory size seems to grow about 4k every 3rd or 4th request. The Perl script we are running is simply:

print "Content-type: text/html\n\n";  print "baby";

Yet that apache process just grows and grows when we slam it with apache benchmark. We are hitting it with:

ab -n 100000 -c 1 http://localhost/search/search.cgi &> /dev/null

and we watch as the process size grows from about 4 megabytes to 24 after about 20000 requests.

To answer the question below: We are doing this on redhat enterprise 4.7. Its been singled out as this because we hit a static file, or a straight up cgi request and the memory does not grow. When we use a PerlHandler Apache::Registry or PerlRun, or just point the PerlHandler to some code that is a handler, then they all leak.

Anyone seen anything like this, or know whats going on?

EDIT:

Thanks for the answers guys. I have used Devel::Cycle and found a leak, but the issue here is we have stripped down our code to printing the header and a statement. There is no way the print function in Perl leaks (I hope....). The memory leak section in Practical Modperl I have read, but it deals with coding issues, and again unless there is an issue with Perl's print function it is not the code.

like image 729
jacob Avatar asked Jan 21 '09 19:01

jacob


People also ask

How do I find out what is causing my memory leak?

One way to check for memory leak is to press and hold down your Windows key and tap the Pause/Break key to bring up System Properties. Click on the Performance tab and check System Resources for the percentage of free or available RAM.

Do memory leaks show in Task Manager?

The short answer: It's not possible. With only looking at task manager, there just ins't enough data available. A memory leak typically is memory that is still allocated, but isn't used anymore; to the task manager, however, it looks as if the process would still use that memory (and it has no way of finding out).

How do you find memory leaks on the app?

The Memory Profiler is a component in the Android Profiler that helps you identify memory leaks and memory churn that can lead to stutter, freezes, and even app crashes. It shows a realtime graph of your app's memory use and lets you capture a heap dump, force garbage collections, and track memory allocations.


1 Answers

Have you taken a look at the excellent Practial mod_perl and its chapter on memory leaks?

like image 154
innaM Avatar answered Oct 17 '22 11:10

innaM