From 759e02bdaa12b055f58b734f59ee36626a10b49c Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 13 Jul 2024 18:05:19 -0700 Subject: [PATCH] debug mem issues show growth --- litellm/proxy/common_utils/debug_utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/litellm/proxy/common_utils/debug_utils.py b/litellm/proxy/common_utils/debug_utils.py index 9d8d35e19..fb1b9004e 100644 --- a/litellm/proxy/common_utils/debug_utils.py +++ b/litellm/proxy/common_utils/debug_utils.py @@ -9,6 +9,19 @@ from litellm._logging import verbose_proxy_logger router = APIRouter() if os.environ.get("LITELLM_PROFILE", "false").lower() == "true": + try: + import objgraph + + print("growth of objects") # noqa + objgraph.show_growth() + print("\n\nMost common types") # noqa + objgraph.show_most_common_types() + roots = objgraph.get_leaking_objects() + print("\n\nLeaking objects") # noqa + objgraph.show_most_common_types(objects=roots) + except: + pass + tracemalloc.start(10) @router.get("/memory-usage", include_in_schema=False)