This project has moved and is read-only. For the latest updates, please go here.

Performance issue

Jan 20, 2014 at 1:38 PM
Edited Jan 20, 2014 at 1:50 PM

First of all, great library. I am playing around with it for a number of different scenarios. However I have noticed some performance issues. I was wondering whether I am doing something wrong?

So I am trying to run this code with a standard 10 page PDF (paper from google scolar) on a machine with 6 cores and 24GB of ram.
if (!File.Exists(pathOfPdf))
    throw new FileNotFoundException("Invalid path");

var settings = new MagickReadSettings
    Density = new MagickGeometry(595,841)

using (var images = new MagickImageCollection())
    images.Read(pathOfPdf, settings);

    //do stuff with pages here
However it takes a couple of minutes to completes and eats up about 1,5GB of memory which seems kind of excessive for this kind of basic operation.

I enabled logging and posted the output
Jan 20, 2014 at 2:29 PM
The reason it is using so much memory is because of the size of your image. It will use 5058 x 9251 x 16 bytes per pixel = 748664928 bytes = 740MB per page. At some point ImageMagick will switch to disk instead of memory. This will dramatically decrease the performance of your application. The default values that are being used for this will change in the next version of Magick.NET. Contact me through CodePlex if you are interested in using a development version of the x64 .NET 4.0 build that includes these fixes.

You can also handle each page separately instead of reading them all at once. You can specify the page with the FrameIndex property of MagickReadSettings. This will reduce the total amount of memory that is being used.