---
title: "Finding and Fixing Ghostty's Largest Memory Leak"
url: https://daily.dev/posts/finding-and-fixing-ghostty-s-largest-memory-leak-e80o1yj0s
source_url: https://mitchellh.com/writing/ghostty-memory-leak-fix
type: article
source: "Mitchell Hashimoto"
published: 2026-01-10T18:26:13.707Z
updated: 2026-01-10T18:26:35.265Z
tags: ["performance", "zig"]
reading_time: 7
upvotes: 14
comments: 4
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Finding and Fixing Ghostty's Largest Memory Leak

**[Mitchell Hashimoto](https://daily.dev/sources/mitchellh)** · 7 min read · 14 upvotes · 4 comments

## Summary

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.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://mitchellh.com/writing/ghostty-memory-leak-fix>

## Community discussion

Top comments from developers on daily.dev.

**@ghost** · 0 upvotes

> Am I the only one who thinks this whole thing with managing non-standard and standard pages was a bit over engineered.

**@frear** · 0 upvotes

> We got used to it, why are they fixing it? Golden feature, when you move ghostty between displays and it got shut down all of a sudden, leaving the mouse pointer by itself, freeing all your claude code tabs. That should stay like more than a year so everyone will learn how to save the ids of sessions.

---

Tags: [#performance](https://daily.dev/tags/performance), [#zig](https://daily.dev/tags/zig)

[View this post on daily.dev](https://daily.dev/posts/finding-and-fixing-ghostty-s-largest-memory-leak-e80o1yj0s)
