Page 1 of 1
ReadImage constitue.c consumes memory
Posted: 2009-09-23T01:01:08-07:00
by udayakumar
thought I should submit here for anyone authored the ReadImage function in constitute.c.
I tested 32 page TIFF file. This is merely a 2.8Mb in disk. To experiment I just called the ReadImages() in MagickNet and the memory consumed after loading was 1.6Gb.
my sample code is;
string file = "c:\temp\abc.tiff";
ImageMagickNET.ImageList imlist = new ImageMagickNET.ImageList();
imlist.ReadImages(file);
Message.Show("pause here to check the taskmanager memory usage");
When I check the memory in the task manager the cosumed memory is about 1.6Gb.
It does not look like an expected behaviour.
Anyone else experienced this behaviour? I am using ImageMagick 6.5 latest release.
Re: ReadImage constitue.c consumes memory
Posted: 2009-09-23T04:27:37-07:00
by magick
Re: ReadImage constitue.c consumes memory
Posted: 2009-09-23T07:24:39-07:00
by udayakumar
I think this behaviour is not by design. When I say a file that is 2.8M to look 1.3G does not look normal.
Re: ReadImage constitue.c consumes memory
Posted: 2009-09-23T07:47:49-07:00
by magick
It does not matter how well the image compresses on disk, the ImageMagick pixel cache is scaled by the image size and quantum depth. Assume you have 32 1024x1024 images and ImageMagick is Q16. Each pixel consumes 4 color components at 16-bits. So 32*1024*1024*8 is 1/4 GB. Now transform the image, let's say we resize it to double size. That's an addition 1/2GB of memory or disk resources. We're now at 3/4 GB. If your images are colormapped it requires an extra color channel and now you are consuming 1GB of memory. You can save half the memory requirement by installing the Q8 version of ImageMagick at 8-bits per pixel component. You can also create the pixel cache on disk rather than memory like this:
- convert -limit area 1 image.tif image%d.jpg
Re: ReadImage constitue.c consumes memory
Posted: 2009-09-23T09:19:17-07:00
by udayakumar
How do I create a pixel cache in the disk rather than memory. I am using the Imagemagick .net wrapper. Is there a C++ interface to specify the cache location?
Re: ReadImage constitue.c consumes memory
Posted: 2009-09-23T09:25:27-07:00
by magick
You can force the pixel cache to disk with the MAGICK_AREA_LIMIT environment variable (see
http://www.imagemagick.org/script/resou ... nvironment). Or set it as a matter of policy (see
http://www.imagemagick.org/script/resou ... #configure). Or from the MagickCore API, use SetMagickResourceLimit(). Perhaps there is a similar method in MagickNet.
Re: ReadImage constitue.c consumes memory
Posted: 2009-09-23T09:44:54-07:00
by udayakumar
Thanks much that helped somewhat to improve the system responsiveness of the other applications. But slows my applicaiton processing time.
Re: ReadImage constitue.c consumes memory
Posted: 2009-09-23T10:08:37-07:00
by magick
A slow down is expected, disk is 1000 times slower than memory. However, it reduces memory usage by ImageMagick considerably. Its a trade-off.