[Django]-Django memory usage going up with every request

14👍

âś…

I’m afraid I haven’t got any definite answers. Graham Dumpleton’s tips were most helpfull, but unfortunately he didn’t make an answer (just comments), so there is no way to accept his response.

Although I still haven’t fully resolved the issue, here are some basic tips for other people having similar problems:

2👍

We had a similar issue on Webfaction, but it turned out it wasn’t because of them at all. There’s a bug in Django about high memory usage when using the sitemap with lots of elements: http://code.djangoproject.com/ticket/11572

When we removed the sitemap it doesn’t shoot up 90 Mb at the time any longer. Just thought I should mention it since it took a long time for use to troubleshoot.

1👍

I have the same problems with webfaction.

The method I use, and which webfaction told me I should keep using, is run a cron job that checks the memory every 5 minutes or so, and restarts any apps that are getting out of control.

Out of 4 python apps on webfaction, I average 4 restarts per day.

1👍

1👍

I’d suggest not to guess.

Take a look at http://code.google.com/p/django-dowser/, it is a very useful app for detecting memory leaks and figuring out what parts of your code are responsible for memory consumption.

1👍

Check if the in-process memory cache backend is enabled, if yes, that could be the problem (new cache entries at each request).

0👍

I’ve had issues with memory on Webfaction too – they didn’t really crop up until I added my fifth application though. I tried a few tweaks to my apache configs, but what finally worked for me was just switching over to mod_wsgi.

0👍

Are both mod_python and mod_wsgi modules loaded into apache?

I know mod_wsgi doesn’t like having mod_python in its building. Check its not loaded.

Leave a comment