Skip to content

Spring MCP Server connecting to MCP gateway 0.9.0 facing JVM OutOfMemoryError despite limited number of requests #1549

@ikauwsp

Description

@ikauwsp

We are encountering a memory leak issue in our Spring-based MCP server (spring-ai-bom version 1.1.0), which is deployed behind 0.9.0 MCP Gateway. The pod consistently runs for about 3 days before crashing with a java.lang.OutOfMemoryError, even under low request volume.

High-level design:
users → MCP Gateway → Spring MCP Server → APIs

The server is not called directly by users, only through the MCP Gateway

Server Protocol: Streamable HTTP, Sync

Observed behavior

Case 1: Server running without MCP Gateway
• Old Gen heap remains stable
• No OOM occurs
• Memory usage behaves normally under idle

Case 2: Server running with MCP Gateway
• Old Gen heap shows a steady increase over time
• Eventually leads to OutOfMemoryError
• Behavior is reproducible
• Issue only occurs when connected through the Gateway

Suspicion / Hypothesis

From logs and runtime behavior, we observed:
• Frequent client initialization events from the Gateway
• Default health check interval = 60s
• New connections appear to be created repeatedly
• Possible accumulation of:
• idle sessions
• HTTP objects
• SSE connections
• request metadata

We suspect:

The Gateway may be creating new client sessions or HTTP connections repeatedly and not closing them properly.

This could lead to:
• Idle connections piling up
• Objects escaping GC
• Promotion into Old Gen
• Eventual memory exhaustion

We’re wondering:
• Does the MCP Gateway expose configuration for:
• connection reuse?
• session cleanup?
• health check behavior?
• timeout / eviction?
• Is there a best practice for managing long-lived connections in this setup?

If helpful, we can provide more context, jvm old gen heap trends, logs.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions