I've got a legacy Perl CGI page running on Apache that processes a sizable Stand out spreadsheet price of data, contributing to the database as necessary. It will get processed in categories of data, and every number of data will get delivered to the database.

After each call towards the database, my system's available memory decreases considerably to the stage where there's no memory left. After I finally obtain the 'Premature finish of script headers' error and HTTP Code 500 is came back towards the client, the memory is freed back somewhere.

Searching with the (complicated) code, I can not find in which the memory leak may be occurring. Can there be some trick or tool will be able to use to find out in which the memory is certainly going?

Rapid answer is it sucks to become you. There is not a pleasant, ready-to-use program that you could go to have your call answered. I apologize which i could not become more help, but without seeing any code, etc, there really is not much better suggest that anybody can provide.

I can not discuss your unique situation, but here are a few things I have done previously. You need to discover the overall area that's leading to the issue. It isn't very different than other debugging techniques. Usually I've found that there are no elegant means to fix this stuff. You simply roll-up your masturbator sleeves and stick your arms elbow-deep within the muck regardless of how bad it smells.

First, run this program outdoors from the web server. Should you still begin to see the problem in the command line, be at liberty: you simply (mostly) eliminated an issue with the net server. This may take some work to create a wrapper script to setup the net atmosphere, however it eventually ends up being much simpler since you don't have to wreck havoc on restarting the server, etc to totally reset the atmosphere.

If you cannot replicate the issue outdoors the server, you are able to still do things i recommend next, it is simply more annoying. Whether it's a webserver problem and no problem in the command line, the job becomes the invention concerning the distinction between individuals two. I'd experienced situations like this.

When not an issue with the net server, start bisecting the script as if you would for just about any debugging problem. For those who have logging enabled, switch it on watching this program run while recording its real memory use. When will it inflate? It may sound like it is simplified lower with a database calls. If you can to operate this in the command line or even the debugger, I'd look for a pair appropriate breakpoints pre and post the memory increase and progressively bring them closer together. You may use modules for example Devel::Size to check out memory dimensions for data structures you think.

After that it is simply thinning lower the suspects. Once you discover the suspect, try to replicate it inside a short example script. You need to eliminate as numerous adding-factor options as you possibly can.

When you think you've found the problem code, you may can request another question that shows the code should you still do not understand what's happening.

Should you desired to get really fancy, you can write your personal Perl debugger. It isn't very difficult. You receive a opportunity to run some subroutines within the DB namespace at the start or finish of claims. You've your debugging code list memory profiles for that items you suspect and search for jumps in memory dimensions. I would not do this unless of course anything else fails.