question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hello! 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:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:24 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
agronickcommented, Nov 29, 2018

Everything is looking good after a few days in prod: annotated

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.

3reactions
andrewgodwincommented, Nov 29, 2018

Great. channels_redis is released already and I’ll try to get other releases out this week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Memory leak - Wikipedia
In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in...
Read more >
What is Memory Leak? How can we avoid? - GeeksforGeeks
Memory leak occurs when programmers create a memory in heap and forget to delete it. The consequences of memory leak is that it...
Read more >
Definition of memory leak - PCMag
When memory is allocated, but not deallocated, a memory leak occurs (the memory has leaked out of the computer). If too many memory...
Read more >
Memory leak - OWASP Foundation
A memory leak is an unintentional form of memory consumption whereby the developer fails to free an allocated block of memory when no...
Read more >
Find a memory leak - Windows drivers - Microsoft Learn
A memory leak occurs when a process allocates memory from the paged or nonpaged pools, but doesn't free the memory.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found