I have a Django application that keeps going over its memory limit and I cannot figure out how to trace this back. Are there good ways to find what causes a runaway process? Is there a way to automatically kill an Apache worker if they get over a certain memory limit? asked 18 Jan '12, 15:22 tclancy |
You can debug Apache/mod_wsgi processes with First, make a note of the process id and command of whatever process is using a lot of memory or CPU. You can get that info by running:
Next, invoke
Once you are in
Next, you need to see the active threads by running:
The threads will be shown in a numbered list - switch to the thread that has your process id. For example, if the thread was #4:
Finally, generate a Python traceback for whatever that thread is chewing on:
With any luck, This doesn't always work as described above, for example if Apache isn't actually spinning on a Python operation. However, you can still use Hope that helps! answered 18 Jan '12, 16:48 seanf |
Thanks for this awesome tip seanf. I did some more research and found a gdb script that helps automate this: Download script and copy it to your gdb config file:
Run gdb with the PID of your process and then run the
answered 17 May '12, 18:33 Michael Bunsen |