The short answer is that it sucks to be you. There isn't a nice, ready-to-use program that you can run to get an answer. I'm sorry that I couldn't be more help, but without seeing any code, etc, there really isn't any better advice that anyone can give.
I can't talk about your particular situation, but here are some things I've done in the past. It's important to find out the general area that's causing the problem. It's not much different than other debugging techniques. Usually I find that there's no elegant solution to these things. You just roll up your sleeves and stick your arms elbow-deep in the muck no matter how bad it smells.
First, run the program outside of the web server. If you still see the problem from the command line, be happy: you just (mostly) ruled out a problem with the web server. This might take a little bit of work to make a wrapper script to set up the web environment, but it ends up being much easier since you don't need to mess with restarting the server, etc to reset the environment.
If you can't replicate the problem outside the server, you can still do what I recommend next, it's just more annoying. If it's a webserver problem and not a problem from the command line, the task becomes the discovery about the difference between those two. I'd encountered situations like that.
If it's not a problem with the web server, start bisecting the script like you would for any debugging problem. If you have logging enabled, turn it on and watch the program run while recording its real memory use. When does it blow up? It sounds like you have it narrowed down to some database calls. If you are able to run this from the command line or the debugger, I'd find a pair appropriate breakpoints before and after the memory increase and gradually bring them closer together. You might use modules such as Devel::Size to look at memory sizes for data structures you suspect.
From there it's just narrowing down the suspects. Once you find the suspect, see if you can replicate it in a short example script. You want to eliminate as many contributing-factor possibilities as possible.
Once you think you've found the offending code, maybe you can ask another question that shows the code if you still don't understand what's going on.
If you wanted to get really fancy, you could write your own Perl debugger. It's not that hard. You get a chance to run some subroutines in the DB
namespace at the beginning or end of statements. You have your debugging code list memory profiles for the stuff you suspect and look for jumps in memory sizes. I wouldn't try this unless everything else fails.