mistercrunch commented on code in PR #35061:
URL: https://github.com/apache/superset/pull/35061#discussion_r2331694670


##########
superset/initialization/__init__.py:
##########
@@ -638,6 +638,17 @@ def apply_http_headers(response: Response) -> Response:
                     response.headers[k] = v
             return response
 
+        @self.superset_app.after_request
+        def cleanup_analytics_memory(response: Response) -> Response:
+            """Force garbage collection after each request if feature flag 
enabled"""
+            if feature_flag_manager.is_feature_enabled(
+                "FORCE_GARBAGE_COLLECTION_AFTER_EVERY_REQUEST"
+            ):
+                import gc
+
+                gc.collect()

Review Comment:
   Been thinking about that, but if GC work is work that gets accumulated and 
needs to be processed at python's leisure at some point, seems like in-between 
request is the best time to do it. Also insures it remains small/contained. 
Overall it's not that scary to me. Unless there's some intricate thread or GIL 
issue I'm missing...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to