Long-running Python app using LangGraph/LangChain (asyncio.gather with create_task, one graph per task). Memory grows steadily over time, but only when LangSmith tracing is enabled. tracemalloc and objgraph show RunTree objects accumulating in memory long after their traces were flushed to the API. langsmith 0.4.27, langchain 0.3.27, langgraph 0.6.7.
LangSmith Python SDK memory grows in long-running apps (RunTree kept in memory)
A maintainer confirmed this is expected behavior rather than a leak: the Python SDK keeps the whole run tree (parents, children, inputs/outputs, metadata) in memory while a trace is live, so RSS grows with concurrency and only releases when the root run finishes. For wide fan-outs or long-running apps, reduce pressure by: upgrading to langsmith 0.4.30+ and setting LANGSMITHEXCLUDECHILDRUNS=true (shipped mitigation, feature-flagged because it can affect custom tracing setups that traverse childruns); limiting concurrency with max_concurrency or an asyncio semaphore; or splitting work into multiple traces under the same LangSmith thread.
Source: https://github.com/langchain-ai/langsmith-sdk/issues/2009
Source: https://github.com/langchain-ai/langsmith-sdk/issues/2009