hermes - 💡(How to fix) Fix [Bug]: TUI JavaScript heap out of memory with large context model

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Root Cause

After investigation:

  1. TUI has MAX_HISTORY = 800 limit for messages in memory
  2. Virtual scrolling is implemented (useVirtualHistory)
  3. However, the Ink/React rendering engine appears to have memory accumulation issues during long streaming sessions
  4. The crash occurred after ~7 minutes of continuous streaming output at 13% progress

Fix Action

Workaround

Added NODE_OPTIONS="--max-old-space-size=12288" to increase Node.js heap limit to 12GB, but this is not a sustainable solution.

Code Example

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
RAW_BUFFERClick to expand / collapse

Bug Description

TUI crashes with JavaScript heap out of memory error after several rounds of conversation, especially when using models with large context windows (200k tokens).

The Node.js process running the TUI (Ink/React-based) consumes excessive memory and eventually crashes with:

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Steps to Reproduce

  1. Run hermes --tui
  2. Use a model with large context (e.g., GLM-5 with 200k context)
  3. Have a conversation with multiple tool calls (50+ messages)
  4. After several rounds, TUI crashes with OOM error

Expected Behavior

TUI should handle long conversations without running out of memory, or at least have configurable memory limits exposed to users.

Actual Behavior

TUI crashes silently, terminal returns to shell prompt. The Node.js heap usage reaches ~8GB before crashing.

Environment

  • Operating System: Linux (Ubuntu)
  • Python Version: 3.x
  • Hermes Version: v0.10.x (latest)
  • Model: GLM-5 (200k context length)
  • Node.js Memory Limit: Default (~4GB), tried 8GB still insufficient

Root Cause Analysis

After investigation:

  1. TUI has MAX_HISTORY = 800 limit for messages in memory
  2. Virtual scrolling is implemented (useVirtualHistory)
  3. However, the Ink/React rendering engine appears to have memory accumulation issues during long streaming sessions
  4. The crash occurred after ~7 minutes of continuous streaming output at 13% progress

Workaround

Added NODE_OPTIONS="--max-old-space-size=12288" to increase Node.js heap limit to 12GB, but this is not a sustainable solution.

Related Issues

  • #12923 (similar report on WSL)

Proposed Fix

Suggestions:

  1. Expose Node.js memory limit as a configurable option in config.yaml
  2. Investigate memory leaks in Ink/React rendering during streaming
  3. Consider periodic garbage collection hints during long operations
  4. Limit the amount of data kept in memory for streaming state

Additional Context

This issue is reproducible and affects usability significantly. The existing issue #12923 reports the same symptom but on WSL. This report confirms it also occurs on native Linux with large context models, suggesting the root cause is in the TUI rendering layer, not platform-specific.

extent analysis

TL;DR

Increase the Node.js heap limit and investigate memory leaks in the Ink/React rendering engine to prevent TUI crashes due to excessive memory consumption.

Guidance

  • Verify the current Node.js heap limit and consider increasing it as a temporary workaround using NODE_OPTIONS="--max-old-space-size=<size>".
  • Investigate memory leaks in the Ink/React rendering engine during long streaming sessions by monitoring heap usage and identifying potential memory accumulation issues.
  • Consider implementing periodic garbage collection hints during long operations to mitigate memory consumption.
  • Review the MAX_HISTORY limit and virtual scrolling implementation to ensure they are not contributing to memory accumulation.

Example

No code snippet is provided as the issue is more related to configuration and memory management.

Notes

The proposed fix suggests exposing the Node.js memory limit as a configurable option, which may help mitigate the issue. However, the root cause of the memory leaks in the Ink/React rendering engine needs to be investigated and addressed.

Recommendation

Apply a workaround by increasing the Node.js heap limit and investigate memory leaks in the Ink/React rendering engine, as the issue is not fully resolved and requires further investigation.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING