Ghostty's creator details a memory leak that caused the terminal emulator to consume up to 37 GB of memory after extended use. The bug stemmed from a scrollback optimization that reused pages but incorrectly reset metadata to standard size while leaving large mmap allocations intact, preventing munmap from being called. The issue became prominent with Claude Code's CLI, which produces many multi-codepoint graphemes requiring non-standard pages. The fix prevents reusing non-standard pages during scrollback pruning, instead properly freeing them and allocating fresh standard-sized pages from the pool.
Table of contents
The PageListThe Scrollback OptimizationThe BugThe FixFinding the Leak with VM TagsThanksFootnotes4 Comments
Sort: