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.
This commit is contained in:
Tomasz Pankowski 2025-04-05 00:13:34 +02:00
parent b78b5a210b
commit 9225f8bb28

View file

@ -1525,6 +1525,7 @@ class Flask(App):
error = None
ctx.pop(error)
del error
def __call__(
self, environ: WSGIEnvironment, start_response: StartResponse