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

New Post: Memory Leak in Creating MagickImage Object From MPC Files

$
0
0
I had a problem with memory leak in our system for couple of months. I was searching and investigating whenever I was less busy during these months. This week I focused on this issue and I found it. I believe it is related to MagickImage object. I build a whole new MVC application to test it in a fresh environemt.
here is the code in the controller that creat 200 MagickImage from mpc file which is created with the same MagickNet version.



public JsonResult BuildMagickFromCache()
    {
        for (int i = 0; i < 200; i++)
        {
            using (var myMagickImage = new MagickImage(@"D:\temp\test.mpc"))
            {
                int j = i;
                j++;
            }

        }
        return new JsonResult { Data = "done   " + DateTime.Now.Second.ToString(), JsonRequestBehavior = JsonRequestBehavior.AllowGet };

    }
everytime I hit this action it added about 250 Mg into the memory and memory increases over time. so if i hit that action for 4 times my memory is over 1 Gig.
I called GC.Collect() after the loop but no changes in term of memory usage. I called dispose of the MagickImage objects but still there was memory leak.

I wrote a console application in c# to test it in a exe program. This time memory increases very little every time. for example couple of Mg not hunderends of Mg . However the graph of memory usage still is increasing. Is there any settings or configuration ? or it is a bug in creating MagickImage from mpc files?

static void Main(string[] args)
    {

        bool continueThisLoop = true;

        while (continueThisLoop)
        {

            for (int i = 0; i < 200; i++)
            {
                using (
                    var mymagick = new MagickImage(@"D:\temp\test.mpc"))
                {
                    int b = 9;
                    int c = b;
                }
            }


            var read = Console.ReadLine();
            if (read == "exit")
                continueThisLoop = false;
        }
    }

I use :
MagickNet 7.0.3.500 any cpu 8
Visual studio 2015
IIS 10

Viewing all articles
Browse latest Browse all 3693

Trending Articles



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