diff --git a/litellm/proxy/common_utils/debug_utils.py b/litellm/proxy/common_utils/debug_utils.py index 9d8d35e196..fb1b9004e7 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)