Giter Club home page Giter Club logo

Comments (4)

Therzok avatar Therzok commented on August 20, 2024

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:

  • It might not be an actual leak. If the memory goes down after a while, it's just that it's waiting for finalization, since disposal will only release of the native resources.
  • StopAnimation doesn't work, since _idTimer isnt' set.
  • Disposing Context.Target is not necessary.

I looked over the methods you're using and their refcounting semantics in gtk#, and they don't seem wrong.

from gtk-sharp.

Rombersoft avatar Rombersoft commented on August 20, 2024

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:

https://github.com/Rombersoft/pango-sharp-bug/blob/7135ee9a24bd94026ff59dba78c936abb8c95139/Simple_GTK/GraphicsController.cs#L140

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

from gtk-sharp.

Therzok avatar Therzok commented on August 20, 2024

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:

  • You have a timeout on a 30ms interval
  • You keep creating surfaces
  • At some point, OnDrawn will run, and you'll only dispose one of them.

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.

from gtk-sharp.

Rombersoft avatar Rombersoft commented on August 20, 2024

This will not resolve problem with pango.

from gtk-sharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.