Rmagic memory use while resizing images
When resizing images memory usage increases by 40 MB to 80ish MB. These are on files that vary in size but none of them are bigger then 300 kb.
After a bit of profiling I found the offending method.
def avatar_resize path
img = Magick::Image.read(path).first
img.resize_to_fit(200,200).to_blob
end
Is this big increase in memory usage 开发者_如何学Gonormal or do I need to do something else to eliminate these huge spikes?
Do you need to create or composite images? If not you could use using mini magick instead. Rmagick shares memory with rails while mini magick has a separate memory allocation for mogrify.
I would probably try and avoid using .to_blob and write the image to file as that is storing your image in memory as is most likely contributing to your high memory usage.
精彩评论