Quantcast
Channel: magick Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 1011

Created Unassigned: Memory leak of unmanaged memory when resizing and compressing pictures [1246]

$
0
0
Our applications is constantly growing in memory. It is a .NET 4.5 application, but our tools shown that the growing memory is unmanaged memory.

We reproduced the same problem with the following example :

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MagickLeak
{
class Program
{

static byte[] getPicture(int _iWidth, int _iHeight)
{
byte[] l_arResult = new byte[_iWidth * _iHeight * 4];
Random randNum = new Random();
randNum.NextBytes(l_arResult);
return l_arResult;
}

static void sendPicture(byte[] _arPicture)
{

}

static void Main(string[] args) {

int l_iOldWidth = 1900;
int l_iNewWidth = 640;
int l_iOldHeight = 1080;
int l_iNewHeight = 480;

ImageMagick.MagickImage l_Image = new ImageMagick.MagickImage();

ImageMagick.MagickReadSettings l_ReadSettings = new ImageMagick.MagickReadSettings();
l_ReadSettings.Width = l_iOldWidth;
l_ReadSettings.Height = l_iOldHeight;
l_ReadSettings.Format = ImageMagick.MagickFormat.Bgra;

ImageMagick.MagickGeometry l_Geo = new ImageMagick.MagickGeometry(l_iNewWidth, l_iNewHeight);
l_Geo.IgnoreAspectRatio = true;

while (true)
{
byte[] l_arData = getPicture(l_iOldWidth, l_iOldHeight);
l_Image.Read(l_arData, l_ReadSettings);

l_Image.Scale(l_Geo);
l_Image.Format = ImageMagick.MagickFormat.Jpeg;

using (System.IO.MemoryStream l_Out = new System.IO.MemoryStream()) {
l_Image.Write(l_Out);
sendPicture(l_Out.GetBuffer());
}

System.Threading.Thread.Sleep(50);
}
}
}
}
```

This program slowly grows in memory.

We use the last version of Magick .NET ( Magick.NET-6.8.9.101-Q8-x86-net40-client).

Viewing all articles
Browse latest Browse all 1011

Trending Articles



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