Open Rombersoft opened 6 years ago
I'll take a look at the sample and figure it out.
On the note of what's going on, I see no obvious retention of memory through classic event handler leaking.
Is this the latest version of gtk-sharp-2-12-branch
?
Few things to note:
_idTimer
isnt' set.I looked over the methods you're using and their refcounting semantics in gtk#, and they don't seem wrong.
Thank you as for "StopAnimation doesn't work, since _idTimer isnt' set." I'll fix it
This bug happens on all GTK# versions
As for waiting for finalization I can wait BUT HOW MANY minutes I must wait? Say me quantity of waiting minutes and I will do experience.
Also I would want to pay your attention to this line:
Every time when I redraw this ImageSurface I must create new instance at the begin of method and dispose it at the end of method otherwise if I use one instance again and again my memory also leaks very fast. I think that is not right to create new ImageSurface for every animation step because it is bad performance. Maybe it exists some way to clear this surface without creating new instance
I'm seeing this when running locally:
Set MONO_CAIRO_DEBUG_DISPOSE to track allocation traces
Cairo.Surface is leaking, programmer is missing a call to Dispose
Set MONO_CAIRO_DEBUG_DISPOSE to track allocation traces
Cairo.Surface is leaking, programmer is missing a call to Dispose
The native memory is not reclaimed in the finalizer for surface. I haven't touched Cairo itself for how it manages native memory, so this is a cairo bug, not a pango bug.
The code you linked here: https://github.com/Rombersoft/pango-sharp-bug/blob/7135ee9a24bd94026ff59dba78c936abb8c95139/Simple_GTK/GraphicsController.cs#L140
The thing with _surface is that you have no guaranteed order of events here. OnDrawn
does not necessarily run right after QueueDraw
is called.
So, what happens is:
So, that means, you should dispose of all the ImageSurfaces you create.
public void FillCommonToBuffer()
{
if (_surface != null)
_surface.Dispose(); // Check this! leaks fixed.
_surface = new ImageSurface(Format.ARGB32, _width, _height);
That made memory stable for me. I also got rid of all the GetTarget().Dispose()
calls everywhere.
This will not resolve problem with pango.
When I use this code
My memory leaks every 2 seconds += 2Mb.
When I comment this code memory alocate is permanent
version pango are 2.99 & 2.12
Demonstrative video and example you can find here https://github.com/Rombersoft/pango-sharp-bug