# Memory Leak Django

**URL:** <https://forum.djangoproject.com/t/memory-leak-django/32698>\
**Category:** Forms & APIs\
**Created:** [July 4, 2024, 2:41pm UTC](https://forum.djangoproject.com/t/memory-leak-django/32698 "2024-07-04T14:41:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![emmiraglia](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/emmiraglia/32/22401_2.png) [@emmiraglia](https://forum.djangoproject.com/u/emmiraglia)\
**Post date:** [July 4, 2024, 2:41pm UTC](https://forum.djangoproject.com/t/memory-leak-django/32698/1 "2024-07-04T14:41:15Z")

</div>

Hello I have an issue with a memory leak, after a process the gc doesn’t collect numeric type varibles, I tried with del or casting the variables to none, then calling gc.collect. Do you have any suggestions ? We investigated with memory\_profiler and managed to find those numeric varibles that are not cleaned by gc. I’m posting on the forum because I think that the issue is due to django’s memory management that does not release the memory after the process finishes. Thanks

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 4, 2024, 2:59pm UTC](https://forum.djangoproject.com/t/memory-leak-django/32698/2 "2024-07-04T14:59:31Z")

</div>

Welcome @emmiraglia !

This is actually a Python issue and has nothing directly to do with Django. How memory is managed by Python can be different based upon which version and release of the compiler you are using.

Also keep in mind that your code runs within the context of a larger process. When a view finishes handling a request, the process running that view does _not_ terminate.

If you’re really interesting in understanding how Python manages memory, you can start by reading the [Memory Management — Python 3.12.4 documentation](https://docs.python.org/3/c-api/memory.html), [Design and History FAQ — Python 3.12.4 documentation](https://docs.python.org/3/faq/design.html#id16), and [Garbage collector design](https://devguide.python.org/internals/garbage-collector/) docs. You’ll also find a number of relevent threads over at [https://discuss.python.org/](https://discuss.python.org/)
