You are leaking a wand.
Here, you allocate a new wand and defer it to destroy:
tx := imagick.NewMagickWand() defer tx.Destroy()
But then further down, in an "if" block, you replace it with the wand that is returned from the call to
tx = mw.TransformImage("", size) tx.SetImageGravity(imagick.GRAVITY_CENTER)
If you completely get rid of the first allocation of that new magick wand, and simply make sure to
Destroy() that new wand returned from
TransformImage(), the leak goes away.
Ref the issue tracker, #72, for details