Memory leak?
See original GitHub issueHello! On the production service we faced with the problem of the constant infinite growth of memory consumption.
To reproduce the problem simple project was created (https://github.com/devxplorer/ws_test).
We test it with script scripts/ws_test.py, which makes opening a connection, sending a message and closing the connection.
For diagnostics we used memory_profiler package. An examples of the resulting graphs when running a test script can be found in the plots/ folder.
Local environment (where the tests was made):
- Linux Mint 18.3 Sylvia
- Python 3.5.2 [GCC 5.4.0 20160609] on linux
- versions of the packages can be found in the
requirements.txt
The conclusions that we have been able to do:
- changing the asgi server does not change the result, memory consumption continues to grow (daphne, uvicorn, gunicorn + uvicorn were tested);
- periodic run of gc.collect() does not change the picture.
Perhaps when creating/closing connections, there is some kind of memory leak in channels?. Or there is some mistake in our code that we are missing.
Maybe someone faced with a similar problem and it turned out to be solved? Any help would be appreciated.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:24 (8 by maintainers)

Top Related StackOverflow Question
Everything is looking good after a few days in prod:
We went from using all the memory on the server (26gb) to 6.7gb with the default number of ASGI_THREADS. I found that the number of ASGI_THREADS is abnormally high if you leave it at the defaults. It was something like 70 threads. I lowered it to 8 and we are now at 2.1 GB for 8 processes with 8 threads each.
Great.
channels_redisis released already and I’ll try to get other releases out this week.