Django Postgres memory leak
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Music Box Puzzles
--
Chapters
00:00 Question
03:09 Accepted answer (Score 5)
03:59 Thank you
--
Full question
https://stackoverflow.com/questions/6097...
Question links:
https://code.djangoproject.com/ticket/31...
Accepted answer links:
[DEBUG]: https://docs.djangoproject.com/en/3.0/re...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #multithreading #postgresql #memoryleaks
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Music Box Puzzles
--
Chapters
00:00 Question
03:09 Accepted answer (Score 5)
03:59 Thank you
--
Full question
https://stackoverflow.com/questions/6097...
Question links:
https://code.djangoproject.com/ticket/31...
Accepted answer links:
[DEBUG]: https://docs.djangoproject.com/en/3.0/re...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #multithreading #postgresql #memoryleaks
#avk47
ACCEPTED ANSWER
Score 6
Django keeps a reference to all executed queries in a ring buffer when settings.DEBUG = True
From DEBUG documentation
It is also important to remember that when running with
DEBUGturned on, Django will remember every SQL query it executes. This is useful when you’re debugging, but it’ll rapidly consume memory on a production server.
Setting DEBUG = False should address your issue.
To wipe the ring buffer in situations where it may pose a problem in development:
from django.db import reset_queries
if settings.DEBUG:
reset_queries()