-
Notifications
You must be signed in to change notification settings - Fork 182
Open
Description
I noticed that the memory usage for my application (https://github.com/swingmx/swingmusic) grows by ~4MB upto 20MB every time I stream audio files. The memory is never released and grows indefinitely as long as I'm streaming files. Investigating further showed that this only happens when I'm using waitress to serve the app.
I'm not sure whether other non-file sending routes are affected, but the memory increase when sending files is significant. Running the app for a week increases the memory upto ~4GB under moderate usage.
The minimal code that reproduces this problem is pasted below.
Dependencies:
- Waitress
v3.0.2 - Flask
v3.1.0
import waitress
from pathlib import Path
from flask import Flask, request, send_from_directory
app = Flask(__name__)
@app.route("/")
def stream_file():
filepath = request.args.get("filepath")
path = Path(filepath)
if not path.exists():
return "File not found", 404
return send_from_directory(path.parent, path.name)
if __name__ == "__main__":
# app.run(host="0.0.0.0", debug=False,port=1980)
waitress.serve(app=app, port=1980)Please check out the repo that I've setup to help reproduce this issue:
Metadata
Metadata
Assignees
Labels
No labels