Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: out of memory exception thrown

$
0
0
Unfortunately this only solved my issue with not using all the available ram.

There seems to be a serious memory leak in the magick.net library.

As I wrote then I am running it in a multithread scenario and I have made a small component (managed dll) that encapsulates magick image (nquant and image processor libraries).
From my main application (which is where the threads are running) I am calling a function that encapsulate the code I pasted in the first post.

My problem is that the memory consumed by magick.net just keeps increasing and increasing. when it hit the maximum allowed memory then it starts filling the %temp% folder with image magick raw images. Some of these files are deleted but not all which means that eventually this fills the entire hd or maximum allowed space.

Both the managed dll and the main application is specifically target for x64 CPU's/OS's. I have tried to explicitly call dispose on the MagickImage in the code from above, but with no change. I have also removed the Strip() function to see if that should have any influence and it did not.

The reason why I am relatively certain that this issue is related to the magick.net library is that I tried to switch to the ImageProcessor library to do the same thing with the following code:
        using (ImageFactory imageFactory = new ImageFactory())
        {
            // set to beginning of stream
            input.Seek(0, SeekOrigin.Begin);
            // create output stream
            MemoryStream outputStream = new MemoryStream();
            // apply quality setting and output to given image
            imageFactory.Load(input).Format(new JpegFormat()).BackgroundColor(backgroundColor).Quality(quality).Save(outputStream);
            // return the output stream
            return outputStream;
        }
And with the ImageProcessor library there were no memory issues at all. The only difference from the main application is the method that is called in my managed dll. Unfortunately the ImageProcessor library does not give as good image quality as image magick so I would prefer not to switch to it permanently.

Hope someone is able to help!

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>