Drawables memory leak
See original GitHub issueEdit:
- 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:
- Created 5 years ago
- Comments:8 (6 by maintainers)
Top GitHub Comments
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.
I just published Magick.NET 7.8.0.0 that includes a fix for your issue.