mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
internal/atlas: dispose images at ReadPixels
Without resolveDeferred() at ReadPixels, many images are never disposed in tests. Updates #2292
This commit is contained in:
parent
7fab62158d
commit
cdf83ad2fc
@ -576,6 +576,10 @@ func (i *Image) ReadPixels(graphicsDriver graphicsdriver.Graphics, pixels []byte
|
||||
backendsM.Lock()
|
||||
defer backendsM.Unlock()
|
||||
|
||||
// In the tests, BeginFrame might not be called often and then images might not be disposed (#2292).
|
||||
// To prevent memory leaks, resolve the deferred functions here.
|
||||
resolveDeferred()
|
||||
|
||||
if i.backend == nil || i.backend.restorable == nil {
|
||||
for i := range pixels {
|
||||
pixels[i] = 0
|
||||
|
@ -778,6 +778,7 @@ func (g *Graphics) End(present bool) error {
|
||||
if err := g.waitForCommandQueue(); err != nil {
|
||||
return err
|
||||
}
|
||||
g.releaseResources(g.frameIndex)
|
||||
g.releaseVerticesAndIndices(g.frameIndex)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user