question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Drawables memory leak

See original GitHub issue

Edit:

  • updated to Magick.NET-Q16-AnyCPU 7.7.0
  • update VS Code to 1.27.1

Description

I’m running a code over a bunch of images on my computer. I’m resizing 1024x768 images to 512x512. I need to add black borders (because of aspect ratio mismatch) to the 512x512 image. This is why I’m using Drawables class. Here is a snippet that runs over every single image:

            using (MagickImage image = new MagickImage(_inPath, 1024, 768))
            {
                image.Sample(512, 384);

                using (MagickImage result = new MagickImage(MagickColors.Black, 512, 512))
                {
                    result.Quality = 50;
                    
                    //this causes a leak
                    new Drawables()
                    .Composite(0, (512 - 384) / 2, image)
                    .Draw(result);

                    result.Write(_outPath);
                }
            }

I’m looking at the Task Manager while the program is running. Every 10-20 processed image adds about 10mb of RAM to the memory. I have about 10 000 images to go through. After the RAM usage reaches about 2GB the execution slows down drastically. If I stop the program and start it again from the point it stopped running the last time, it again runs at initial speed.

Now if I comment the new Drawables().Coposite().Draw() line and run again, nothing is being added to the memory. The Drawables class does not have a .Dispose() method. So I’m at a bit of a loss here.

Environment:

  • Windows 10 x64
  • AMD A8-7410 APU with AMD Radeon R5 Graphics 220ghz
  • 8GB Ram
  • VS Code 1.27.1
  • .NET Core console application
  • Magick.NET-Q16-AnyCPU 7.7.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dlemstracommented, Sep 14, 2018

Found and fixed the bug! Thanks for reporting this @kasradzenika! This will be resolved in the next release that I will try to publish very soon.

0reactions
dlemstracommented, Sep 22, 2018

I just published Magick.NET 7.8.0.0 that includes a fix for your issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Drawable memory leak : r/androiddev
I have written a small daydream service that changes a picture on the screen every X amount of seconds. But it seems the...
Read more >
Android Drawables memory leak
I work with several large drawables and I don't know how to manage memory leaks. I tracked the heap size of my application...
Read more >
Fixing Memory Leaks in Android - OutOfMemoryError
When you receive an OutOfMemoryError, it generally means, 9 times out of 10 that you have a memory leak. My first impressions of...
Read more >
possible memory leak · Issue #653 - android-gif-drawable
Encountered a situation of possible memory leak, or was it a misusage? ... That pool had a fix number of GifImageView s, and...
Read more >
Preventing and detecting memory leaks in Android apps
Memory leaks occur when an object that is supposed to be garbage collected has something holding a reference to it. As more and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found