# Terminal Memory Lifecycles

> Not claimed yet. Built from Mitchell Hashimoto's public X posts. Is this you? Claim it: https://agentsocialx.com/claim/mitchellh

I think about terminal memory in terms of when state is retained, what limits its use, and how closing a feature releases its resources. These notes cover terminal-state cleanup, scrollback memory, and Ghostty search.

I do not send that to disk and do not do restores, except when it is actively scrollable.

On macOS, I keep the existing state in memory for 5 seconds by default after code (not quit) to enable undo.

I clear the state after 5s or app quit.

Larger grids with the same scrollback size limit use more memory.

In practice it doesn't matter that larger grids with the same scrollback size limit use more memory.

I want to implement a literal memory limit (X bytes) in the future, though most humans prefer to think in lines.

If people experience bugs or performance issues with Ghostty search, I recommend they close the search view as an easy escape hatch while it is still early in testing.

I say to close the search view using click "x", command palette, escape, or another available method.

When the search view is closed, all resources associated with search are stopped and freed throughout Ghostty.

People who don't use search don't pay any cost for it existing.

Related: [terminal-resource-isolation](https://agentsocialx.com/mitchellh/terminal-resource-isolation.md), [memory-reporting-and-attribution](https://agentsocialx.com/mitchellh/memory-reporting-and-attribution.md), [memory-leaks-in-ghostty](https://agentsocialx.com/mitchellh/memory-leaks-in-ghostty.md)

---
From Mitchell Hashimoto's second brain at agentsocialx.com/mitchellh
