Can't limit the resouse used by IM
Posted: 2011-06-17T03:02:10-07:00
I used ImageMagick-6.7.0 to resize lots of pictures and got one large exceptional picture.
It's about 2.7MB. To resize it, Imagick++ used about 1.5GB memory.
Of course, to ensure large images do not consume all the memory on my system, I can force the image pixels to memory-mapped disk with resource limits , see the url: http://www.imagemagick.org/script/archi ... tera-pixel
But, I also don't like to see that the IO on my system is busy. So I want to skip this picture, do not resize them.
I use setrlimit() function to limit the memory and disk resouese used by IM as follow:
I could catch the SIGXFSZ signo, but after catching the SIGXFSZ, my process crashed:
The large image: http://www.ajrice.com/UploadFile/Image/error.gif
How can I find out the exceptional pictures and avoid resizing them?
It's about 2.7MB. To resize it, Imagick++ used about 1.5GB memory.
Of course, to ensure large images do not consume all the memory on my system, I can force the image pixels to memory-mapped disk with resource limits , see the url: http://www.imagemagick.org/script/archi ... tera-pixel
But, I also don't like to see that the IO on my system is busy. So I want to skip this picture, do not resize them.
I use setrlimit() function to limit the memory and disk resouese used by IM as follow:
Code: Select all
if(signal(SIGXFSZ, handle_sigxfsz) == SIG_ERR)
printf("can't catch sigxfsz");
struct rlimit limit;
limit.rlim_cur = 80971520;
limit.rlim_max = 80971520;
ret = setrlimit(RLIMIT_AS, &limit);
limit.rlim_cur = 20097152;
limit.rlim_max = 20097152;
ret = setrlimit(RLIMIT_FSIZE, &limit);
Magick::Blob blob(src_data, src_size);
Image image;
image.read(blob);
Code: Select all
Program terminated with signal 11, Segmentation fault.
#0 0x080b4e56 in QueueAuthenticNexus ()
(gdb) bt
#0 0x080b4e56 in QueueAuthenticNexus ()
#1 0x080b55fc in GetAuthenticPixelCacheNexus ()
#2 0x080b5c46 in GetAuthenticPixels ()
#3 0x0820468e in ReadGIFImage ()
#4 0x080d5728 in ReadImage ()
#5 0x080a92f2 in BlobToImage ()
#6 0x0805ac70 in Magick::Image::read ()
#7 0x0804e6ba in main ()
How can I find out the exceptional pictures and avoid resizing them?