From 9225f8bb28d291b1610c8a58e3233aa6bbdc1808 Mon Sep 17 00:00:00 2001 From: Tomasz Pankowski Date: Sat, 5 Apr 2025 00:13:34 +0200 Subject: [PATCH] fix: explicitly delete error references to prevent memory leaks Add explicit "del error" statement to prevent reference cycles between exception objects and local variables. This helps the garbage collector promptly reclaim memory after request processing, which is especially important in high-traffic web applications where exception objects with traceback information can consume significant memory. --- src/flask/app.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/flask/app.py b/src/flask/app.py index d2743c41..922b44fd 100644 --- a/src/flask/app.py +++ b/src/flask/app.py @@ -1525,6 +1525,7 @@ class Flask(App): error = None ctx.pop(error) + del error def __call__( self, environ: WSGIEnvironment, start_response: StartResponse