How to deal with memory leaks in RMagick in Ruby?

后端 未结 5 676
梦谈多话
梦谈多话 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:19

    Now you can tell ImageMagick which memory space should be used. I think RMAGICK_ENABLE_MANAGED_MEMORY = true and GC.start is what you need.

    MANAGED_MEMORY
    
    If true, RMagick is using Ruby managed memory for all allocations. If false, 
    RMagick allocates memory for objects directly from the operating system. You can 
    enable RMagick to use Ruby managed memory (when built with ImageMagick 6.4.0-11 
    and later) by setting
    RMAGICK_ENABLE_MANAGED_MEMORY = true
    before requiring RMagick.
    

    https://rmagick.github.io/constants.html

    However, image.destroy! itself is enough to stabilize the memory consumption.

提交回复
热议问题