diff --git a/internal/shareable/shareable.go b/internal/shareable/shareable.go index 16118c414..904fc0bd7 100644 --- a/internal/shareable/shareable.go +++ b/internal/shareable/shareable.go @@ -273,6 +273,7 @@ func (i *Image) allocate(shareable bool) { i.backend = &backend{ restorable: restorable.NewImage(i.width, i.height, false), } + runtime.SetFinalizer(i, (*Image).Dispose) return } @@ -280,6 +281,7 @@ func (i *Image) allocate(shareable bool) { if n, ok := b.TryAlloc(i.width, i.height); ok { i.backend = b i.node = n + runtime.SetFinalizer(i, (*Image).Dispose) return } }