# gpui: Free atlas tile space when removing tiles \(\#58874\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/0d8a4d4292dac3fceaa40e73f1bbae038d7de30f)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 0d8a4d4292dac3fceaa40e73f1bbae038d7de30f

Requested commit: 0d8a4d4292dac3fceaa40e73f1bbae038d7de30f

Commit: 0d8a4d4292dac3fceaa40e73f1bbae038d7de30f

Tree: 7a313e2527d0a85e92097887eb038361733ab049

Author: Anthony Eid

Committer: GitHub

## Message

```
gpui: Free atlas tile space when removing tiles (#58874)

Partially addresses #54659

`PlatformAtlas::remove` removed the tile from `tiles_by_key` and
decremented the texture's refcount, but never returned the tile's
rectangle to the etagere allocator. Removed tiles' space could only be
reclaimed if the entire texture was dropped, which doesn't happen if
glyph/emoji share the texture. Because we don't have correct glyph/emoji
removal

I added regression tests on all three platforms to prevent this from
occurring as well.

Note: this doesn't fix glyph eviction or the nil-texture panic from
#54659; those are follow ups.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

- gpui: Fix GPUI memory growing unboundedly when images are repeatedly
loaded and released
```

## Parents

- [dd3521df2b490a93c171b68509880e2f773eeb53](https://git.cafe/gitcafe/zed/commit/dd3521df2b490a93c171b68509880e2f773eeb53?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/0d8a4d4292dac3fceaa40e73f1bbae038d7de30f?format=markdown)
