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.

Memory leak serving static files

See original GitHub issue

Describe the bug The memory of the process is increasing for everytime I request a static file.

Code snippet

import os

app = Sanic(__name__)
here = os.path.dirname(__file__)
app.static("/static", os.path.join(here, "static")

if __name__ == "__main__":
    app.run()

Access a static file. The bigger the file the more memory will be tied up. http://localhost:8000/static/index.html

Expected behavior Memory should be cleared up after serving a static file or at least not linearly increase with each request.

Environment (please complete the following information):

  • OS: macOS BigSur 11.5.2
  • Version 21.9.1

Update: I have been trying to replicate our setup as close as possible and can now quite reliably reproduce the issue. Could you have a look here and let me know if this works for you? https://github.com/seibushin/sanic-mem-leak

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
seibushincommented, Dec 3, 2021

Initial memory usage: image

After holding down command + shift + R for maybe 1 or 2 seconds image

1reaction
seibushincommented, Dec 3, 2021

I have created a repo to reproduce the issue. Could you have a look here? https://github.com/seibushin/sanic-mem-leak

Let me know if that works for you and sorry for the late reply.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js - Memory leak when static file connection is dropped ...
I solved the issue by using nginx to serve static files! Might just be a temporary solution, but it works.
Read more >
memory leak when serving static files · Issue #231 - GitHub
We are not releasing the request buffer when transmitting a static file.
Read more >
[Solved]-Node.js - Memory leak when static file connection is ...
I solved the issue by using nginx to serve static files! Might just be a temporary solution, but it works. Dennis J 176....
Read more >
Lighttpd's memory leaks, a myth or true? If true, does it apply ...
Do Lighttpd's memory leak issues apply when it's serving static content as well? (Most of those complaining are employing Lighttpd to serve ......
Read more >
PK22485: IHS MEMORY LEAK IF FILES BEING SERVED ARE ...
Do not modify static files while the webserver processes is running. Problem summary. A file was truncated while mod_include was reading the file....
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