Skip to content

perf: InMemoryFileStore LRU cache is unbounded per conversation #3146

@csmith49

Description

@csmith49

Problem

Each LocalConversation gets its own InMemoryFileStore with an LRU cache. The cache has no configured maximum size. With N conversations on a server, each accumulating event data, the total memory from file store caches grows without bound.

Location: io/memory.py

Evidence

Code review. Each event is stored as a JSON string in the file store. A conversation with 2000 events at ~500 bytes each = ~1 MB per conversation in the cache alone. With 500 conversations: ~500 MB just in caches.

Severity: High

Impact of fix

Bounded memory per conversation, predictable server memory usage.

Suggested fixes

  • Configure a max cache size per store
  • Or use a shared LRU across conversations with a global memory budget

Related issues and PRs

Discovered during profiling investigation (code review), May 2026. openhands-sdk v1.19.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingperformancePerformance issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions