diff --git a/imagick/drawing_wand.go b/imagick/drawing_wand.go index 68abb8d..36eb0ed 100644 --- a/imagick/drawing_wand.go +++ b/imagick/drawing_wand.go @@ -56,6 +56,7 @@ func (dw *DrawingWand) Destroy() { dw.init.Do(func() { dw.dw = C.DestroyDrawingWand(dw.dw) relinquishMemory(unsafe.Pointer(dw.dw)) + runtime.SetFinalizer(dw, nil) dw.dw = nil dw.DecreaseCount() diff --git a/imagick/image_info.go b/imagick/image_info.go index 4f7be52..e98f129 100644 --- a/imagick/image_info.go +++ b/imagick/image_info.go @@ -27,6 +27,7 @@ func newImageInfo() *ImageInfo { func (ii *ImageInfo) Destroy() { if ii.info != nil { C.DestroyImageInfo(ii.info) + runtime.SetFinalizer(ii, nil) ii.info = nil } } diff --git a/imagick/kernel_info.go b/imagick/kernel_info.go index 141580e..afecf36 100644 --- a/imagick/kernel_info.go +++ b/imagick/kernel_info.go @@ -40,6 +40,7 @@ func newKernelInfo(cki *C.KernelInfo) *KernelInfo { func (ki *KernelInfo) Destroy() { if ki.info != nil { C.DestroyKernelInfo(ki.info) + runtime.SetFinalizer(ki, nil) ki.info = nil } } diff --git a/imagick/magick_wand.go b/imagick/magick_wand.go index 2822b74..fe0bd79 100644 --- a/imagick/magick_wand.go +++ b/imagick/magick_wand.go @@ -65,6 +65,7 @@ func (mw *MagickWand) Destroy() { mw.init.Do(func() { mw.mw = C.DestroyMagickWand(mw.mw) relinquishMemory(unsafe.Pointer(mw.mw)) + runtime.SetFinalizer(mw, nil) mw.mw = nil mw.DecreaseCount() diff --git a/imagick/pixel_iterator.go b/imagick/pixel_iterator.go index 3b5ecfc..2e59189 100644 --- a/imagick/pixel_iterator.go +++ b/imagick/pixel_iterator.go @@ -75,6 +75,7 @@ func (pi *PixelIterator) Destroy() { pi.init.Do(func() { pi.pi = C.DestroyPixelIterator(pi.pi) relinquishMemory(unsafe.Pointer(pi.pi)) + runtime.SetFinalizer(pi, nil) pi.pi = nil pi.DecreaseCount() diff --git a/imagick/pixel_wand.go b/imagick/pixel_wand.go index d31992b..50bcb57 100644 --- a/imagick/pixel_wand.go +++ b/imagick/pixel_wand.go @@ -57,6 +57,7 @@ func (pw *PixelWand) Destroy() { pw.init.Do(func() { pw.pw = C.DestroyPixelWand(pw.pw) relinquishMemory(unsafe.Pointer(pw.pw)) + runtime.SetFinalizer(pw, nil) pw.pw = nil pw.DecreaseCount()