Skip to content

Fix memory leak from recursive print warning flood in hs.ipc#3845

Open
dmgerman wants to merge 1 commit intoHammerspoon:masterfrom
dmgerman:ipc-memory-leak
Open

Fix memory leak from recursive print warning flood in hs.ipc#3845
dmgerman wants to merge 1 commit intoHammerspoon:masterfrom
dmgerman:ipc-memory-leak

Conversation

@dmgerman
Copy link
Copy Markdown

@dmgerman dmgerman commented Feb 1, 2026

The printReplacement recursion guard was using log.w() to warn about recursion, which itself triggers print, causing a cascade of warnings about the recursion. A single hs -c command could generate thousand of warning lines (which make the memory print of hammerspoon to grow extremely fast).

Changes:

  • Add warnedRecursionInstances table to track warned CLI instances
  • Warn only once per instance using originalPrint (not log.w)
  • Clean up tracking tables when instances unregister

The printReplacement recursion guard was using log.w() to warn about
recursion, which itself triggers print, causing a cascade of warnings.
A single hs -c command could generate 86,863 warning lines, and over
9+ hours of usage, this caused memory to grow from ~140 MB to 1.4+ GB.

Changes:
- Add warnedRecursionInstances table to track warned CLI instances
- Warn only once per instance using originalPrint (not log.w)
- Clean up tracking tables when instances unregister
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request does not contain a valid label. Please add one of the following labels: ['pr-fix', 'pr-change', 'pr-feature', 'pr-maintenance']

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 27.39%. Comparing base (b6b3b22) to head (091427a).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3845      +/-   ##
==========================================
+ Coverage   27.22%   27.39%   +0.17%     
==========================================
  Files         191      191              
  Lines       51537    51537              
==========================================
+ Hits        14032    14121      +89     
+ Misses      37505    37416      -89     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants