Skip to content

Memory usage spikes to ~3GB and never releases on coding-agent workload (restart required) #484

Description

@ndaidong

I run 2 GoModel instances with identical configuration (Postgres, Redis, and no semantic caching):

  • Instance A (data processing)

    • ~40k requests/day
    • ~30M tokens/day
    • Memory remains stable and stays < ~150MB
  • Instance B (coding agents)

    • ~1500 requests/day
    • ~20M tokens/day
    • When handling coding-agent workflows, GoModel memory grows very fast, sometimes reaching ~3GB
    • After the spike, memory does not decrease automatically; must restart the container to recover

I suspect the difference is related to how coding agents interact with AI providers. Coding agents typically run in loops and can send many requests in a short time, which may create sudden load. However, GoModel is mainly a middle layer that forwards parameters to providers and returns results, so it shouldn’t need to accumulate that much memory.

This behavior strongly suggests a potential memory leak or an object/lifecycle issue triggered by the coding-agent request pattern.

Please investigate and help identify the cause (memory leak / caching / request lifecycle / concurrency / streaming handling) and propose a fix so memory can be released or bounded under coding-agent workloads.

Image

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Fields

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