mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-13 20:42:07 +01:00
internal/atlas: images were not collected by GC
This commit is contained in:
parent
95f7204035
commit
ba93794a72
@ -624,11 +624,11 @@ func (i *Image) allocate(forbiddenBackends []*backend, asSource bool) {
|
|||||||
panic("atlas: the image is already allocated")
|
panic("atlas: the image is already allocated")
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.SetFinalizer(i, func(img *Image) {
|
runtime.SetFinalizer(i, func(image *Image) {
|
||||||
// A function from finalizer must not be blocked, but disposing operation can be blocked.
|
// A function from finalizer must not be blocked, but disposing operation can be blocked.
|
||||||
// Defer this operation until it becomes safe. (#913)
|
// Defer this operation until it becomes safe. (#913)
|
||||||
appendDeferred(func() {
|
appendDeferred(func() {
|
||||||
i.deallocate()
|
image.deallocate()
|
||||||
runtime.SetFinalizer(i, nil)
|
runtime.SetFinalizer(i, nil)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -38,11 +38,11 @@ func (s *Shader) ensureShader() *restorable.Shader {
|
|||||||
return s.shader
|
return s.shader
|
||||||
}
|
}
|
||||||
s.shader = restorable.NewShader(s.ir)
|
s.shader = restorable.NewShader(s.ir)
|
||||||
runtime.SetFinalizer(s, func(s *Shader) {
|
runtime.SetFinalizer(s, func(shader *Shader) {
|
||||||
// A function from finalizer must not be blocked, but disposing operation can be blocked.
|
// A function from finalizer must not be blocked, but disposing operation can be blocked.
|
||||||
// Defer this operation until it becomes safe. (#913)
|
// Defer this operation until it becomes safe. (#913)
|
||||||
appendDeferred(func() {
|
appendDeferred(func() {
|
||||||
s.deallocate()
|
shader.deallocate()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return s.shader
|
return s.shader
|
||||||
|
Loading…
Reference in New Issue
Block a user