Forums | Admin

Discussion Forums: Hints and Tips

Start New Thread Start New Thread
Message: 41117
BY: Tim Hunter (rmagick)
DATE: 2008-01-30 16:17
SUBJECT: RE: Help! My script runs out of memory!

 

RMagick 2 includes a new method called Magick::Image#destroy! that can help with this problem. This method releases all the unmanaged memory used by an image back to the operating system. Once you destroy an image, calling any other method on that image raises a DestroyedImageError exception.

Here's how to use destroy!:

require 'RMagick'
include Magick

pics = Dir["*.jpg"]
pics.each do |pic|
img = Image.read(pic).first
# process new image
img.destroy!
end


Thread View

Thread Author Date
Help! My script runs out of memory!Tim Hunter2004-09-18 15:25
      RE: Help! My script runs out of memory!Tim Hunter2008-01-30 16:17
            RE: Help! My script runs out of memory!shelly qi2012-09-12 02:32

Post a followup to this message