vector: unused atlas images remain referenced after the image slice shrinks
Ebitengine Version
main (ab841bf203427e7d8208598f58285b686bcfc45a)
Operating System
- Windows
- macOS
- Linux
- FreeBSD
- OpenBSD
- Android
- iOS
- Nintendo Switch
- PlayStation 5
- Xbox
- Web Browsers
Go Version (paste your go version output)
go version go1.27.1 linux/amd64
What steps will reproduce the problem?
In a vector package test, initialize atlas.atlasImages with three 16x16 Ebitengine images and retain a view of that backing slice. Call setPaths with a single 16x16 rectangular path. Inspect the unused backing slice entries after the call.
What is the expected result?
The first image is reused. Images removed from the active slice are deallocated and their references cleared.
What happens instead?
The active slice has length 1, but backing entries 1 and 2 still point to the unused images. The singleton atlas retains that backing array, preventing those images from being collected while the array remains in use.
Anything else you feel useful to add?
Reproduced on main ab841bf203 under Xvfb. This concerns vector's stencil atlas image list, not internal/atlas upload buffers. The proposed change releases only images removed by a nonempty setPaths batch. Repeated growth and shrinkage will trade retained memory for reallocation.
Source: hajimehoshi/ebiten