sanic: Memory leak serving static files
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
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 16 (11 by maintainers)
Initial memory usage:
After holding down command + shift + R for maybe 1 or 2 seconds
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.
Same here. Memory keeps increasing until server crashes. I am not sure if the memory leak is caused by files, but for info, i am using response.file method when i send files. I’ll try to gather more info about this bug. OS: Ubuntu 20.04 sanic==21.6.2