System.Drawing.Common 'Out of memory.'

Carl Yang 1 Reputation point
2021-09-24T09:55:53.86+00:00

When I execute the following code snippet in a Linux environment, an out of memory error occurs.

System.Collections.Stack GraphicsStateStack = new System.Collections.Stack();
Bitmap bmp = new Bitmap(500,600);
Graphics gm = Graphics.FromImage(bmp);
for(int i=0; i<1000; ++i)
{
GraphicsStateStack.Push(gm.Save());
GraphicsState st = (GraphicsState)GraphicsStateStack.Pop();
gm.Restore(st);
st = null;
}
135023-1.png

But I did not find that the memory is being used a lot.
135013-3.png
My environment information is as follows:
135012-2.png

The same code does not report an error under window.
This confuses me.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,608 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Carl Yang 1 Reputation point
    2021-10-13T02:45:17.83+00:00

    This problem seems to be resolved in libggdiplus6.0.5.
    The library I compiled with the latest code does not have this problem.

    0 comments No comments