{"record":{"id":"a79b6e9fe2368f69","repo":"BerriAI/litellm","slug":"objgraph-not-found-please-install-objgraph-to-use","errorCode":null,"errorMessage":"objgraph not found. Please install objgraph to use this feature.","messagePattern":"objgraph not found\\. Please install objgraph to use this feature\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/common_utils/debug_utils.py","lineNumber":100,"sourceCode":"    return {\n        \"total_active_tasks\": len(active_tasks),\n        \"by_name\": dict(counter),\n    }\n\n\nif os.environ.get(\"LITELLM_PROFILE\", \"false\").lower() == \"true\":\n    try:\n        import objgraph\n\n        print(\"growth of objects\")  # noqa: T201\n        objgraph.show_growth()\n        print(\"\\n\\nMost common types\")  # noqa: T201\n        objgraph.show_most_common_types()\n        roots: Final = objgraph.get_leaking_objects()\n        print(\"\\n\\nLeaking objects\")  # noqa: T201\n        objgraph.show_most_common_types(objects=roots)\n    except ImportError:\n        raise ImportError(\"objgraph not found. Please install objgraph to use this feature.\")\n\n    tracemalloc.start(10)\n\n    @router.get(\n        \"/memory-usage\",\n        dependencies=[Depends(user_api_key_auth)],\n        include_in_schema=False,\n    )\n    async def memory_usage():\n        # Take a snapshot of the current memory usage\n        snapshot: Final = tracemalloc.take_snapshot()\n        top_stats: Final = snapshot.statistics(\"lineno\")\n        verbose_proxy_logger.debug(\"TOP STATS: %s\", top_stats)\n\n        # Get the top 50 memory usage lines\n        top_50: Final = top_stats[:50]\n        result: Final = []\n        for stat in top_50:","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/common_utils/debug_utils.py#L82-L118","documentation":"litellm/proxy/common_utils/debug_utils.py runs a block at import time when LITELLM_PROFILE is 'true': it imports objgraph to snapshot object growth and leaking objects. If objgraph is not installed, the ImportError is re-raised with this message. Because the block sits at module import, the proxy fails during startup, not per-request.","triggerScenarios":"Set LITELLM_PROFILE=true in the proxy environment on a host where objgraph is not installed, then start litellm proxy. The env check is case-insensitive ('true').","commonSituations":"A profiling flag left in a base Docker image or helm values. Someone follows a memory-debugging guide that says to set LITELLM_PROFILE=true but skips the dependency step. A shared .env file leaks the flag into CI.","solutions":["Unset LITELLM_PROFILE (or set it to false) if you do not need memory profiling.","Or install the dependency: pip install objgraph.","If profiling is wanted in Docker, add objgraph to the image (custom Dockerfile with pip install objgraph)."],"exampleFix":"# before\nexport LITELLM_PROFILE=true\nlitellm --config config.yaml   # crashes: objgraph not found\n\n# after (option A)\nunset LITELLM_PROFILE\nlitellm --config config.yaml\n\n# after (option B)\npip install objgraph\nexport LITELLM_PROFILE=true\nlitellm --config config.yaml","handlingStrategy":"validation","validationCode":"import importlib.util, os\n\ndef profile_env_ok() -> bool:\n    if os.environ.get(\"LITELLM_PROFILE\", \"false\").lower() != \"true\":\n        return True\n    return importlib.util.find_spec(\"objgraph\") is not None\n\nassert profile_env_ok(), \"install objgraph or unset LITELLM_PROFILE\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Scope LITELLM_PROFILE to the debugging session only; never bake it into base images or .env files committed to the repo.","Add objgraph to the dev/profiling requirements file next to the flag documentation.","If startup fails with this message, check the env first: the flag is usually a leftover."],"tags":["litellm","profiling","dependency","import-error","startup","env-var"],"backgroundTag":"missing-optional-dependency","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}