How to deal with memory leaks in RMagick in Ruby?

后端 未结 5 688
梦谈多话
梦谈多话 2020-12-16 14:31

Im developing web-application with Merb and im looking for some safe and stable image processing library. I used to work with Imagick in php, then moved to ruby and start us

5条回答
  •  鱼传尺愫
    2020-12-16 15:24

    I too have encountered this issue - the solution is to force garbage collection.

    When you have reassigned the image variable to a new image simply use GC.start to ensure the old reference is released from memory.

    On later versions of RMagick, I also believe you can also call destroy! on the image when you have finished processing it.

    A combination of the two would probably ensure you are covered, but im not sure of the real life impact on performance (I would assume it is negligible i most cases).

    Alternatively, you could use mini-magick which is a wrapper for the ImageMagick commandline client.

提交回复
热议问题