Description
I'm having a memory leak in Django Channels using uvicorn
.
Every "memory crash" is a restart/deploy 👇

This not just happens within my project, but also with the tutorial basic chat example.
Here is the repository with that minimal example and memory profiling: https://github.com/cacosandon/django-channels-memory-leak
This happens locally, in the server, with/without DEBUG
, just by reconnecting or sending messages (in the example I've added large messages so you can notice the memory leak).
The memory is never released.. even if the user disconnects after.
I've proved it with memory-profiler
and memray
(both commands were added in the README so you can reproduce)
Dependencies:
Django==5.0.4
channels==4.0.0
channels-redis==4.2.0
uvicorn[standard]==0.29.0
# Profiling memory
memory-profiler==0.61.0
memray==1.12.0
I (think that) have really tried everything; deleting objects, manual garbage collection, etc. Nothing prevents the memory to increase and to never be released back. Any insights? 🙏