Skip to content

perf(terminal): free Kitty image memory a terminal does not draw - #986

Merged
omartelo merged 1 commit into
mainfrom
perf/kitty-image-memory
Oct 29, 2026
Merged

omartelo merged 1 commit into
mainfrom
perf/kitty-image-memory

Conversation

@omartelo

Copy link
Copy Markdown
Collaborator

Follow-up to #985.

  • Hidden terminals let go of their textures. onScreen already released a hidden terminal's renderer pixels (perf(native): release a hidden terminal's renderer images #962), but the Go copies of its Kitty images stayed in kittyImages.textures until it was shown again: Update only runs for terminals on screen. Terminal.ReleaseImages drops them along with t.r.Release(), and the next Update makes again the ones it draws.
  • The placement buffer waits for the first image. Every terminal allocated 1024 placement slots (about 48 KB) at birth. Now update reads the graphics generation and allocates them only once it moves from zero; a plain terminal pays the same one cgo read per frame it paid before.
  • docs/ceilings.md records that a PNG is still decoded with the terminal locked (libghostty calls the decoder inside vt_write), about 20 ms for a 1080p image, and the two ways out if a slow window gets reported.

Test plan

  • TestKittyPlacementBufferOnFirstImage and TestKittyReleaseImagesDropsTextures fail on main and pass here
  • native/: gofmt -l ., go vet ./..., go test ./...

A terminal off screen lets go of its image textures along with its
renderer's pixels, and makes them again when shown. The placement buffer
(1024 slots, about 48 KB) is allocated on a terminal's first image
instead of in every terminal.

docs/ceilings.md records that a PNG is still decoded with the terminal
locked, and the two ways out.
@omartelo
omartelo merged commit 0f9b804 into main Oct 29, 2026
7 checks passed
@omartelo
omartelo deleted the perf/kitty-image-memory branch October 29, 2026 19:06
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.

1 participant