mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +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")
|
||||
}
|
||||
|
||||
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.
|
||||
// Defer this operation until it becomes safe. (#913)
|
||||
appendDeferred(func() {
|
||||
i.deallocate()
|
||||
image.deallocate()
|
||||
runtime.SetFinalizer(i, nil)
|
||||
})
|
||||
})
|
||||
|
@ -38,11 +38,11 @@ func (s *Shader) ensureShader() *restorable.Shader {
|
||||
return s.shader
|
||||
}
|
||||
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.
|
||||
// Defer this operation until it becomes safe. (#913)
|
||||
appendDeferred(func() {
|
||||
s.deallocate()
|
||||
shader.deallocate()
|
||||
})
|
||||
})
|
||||
return s.shader
|
||||
|
Loading…
Reference in New Issue
Block a user