Giter VIP home page Giter VIP logo

Comments (8)

MikeWey avatar MikeWey commented on July 30, 2024

I can also reproduce this on linux, calling core.memory.GC.collect() in the onDraw listener seems to fix this so it looks like it's just that the GC hasn't kicked in yet when resizing like a nut.

from gtkd.

soltanmm avatar soltanmm commented on July 30, 2024

I don't have the exact same issue that was discussed here, but I have a similar issue: I'm rapidly calling an onDraw method and very quickly choking my system memory.

Widget.callBackDraw in src/gtk/Widget.d creates a new object to wrap the Context every time it is called, and it seems to me like such a function would benefit from more usage of the 'scope' keyword. Is this kind of an approach a straightforward fix or is that part of the code entirely autogenerated?

from gtkd.

MikeWey avatar MikeWey commented on July 30, 2024

Isn't that use of scope being depreciated?

Also what will happen when the user stores a copy of the Context somewhere and the class is destructed at the end of the callback because it's scope or explicitly deleted?

The callback receives a new context from Gtk every time it's called, so we cant reuse the old one.

from gtkd.

soltanmm avatar soltanmm commented on July 30, 2024

scope: News to me. I haven't seen that anywhere in the docs. I'd trust you if you said it was, though.

Context: That's what I mean; I was under the impression that the Context would be unusable outside of the draw signal call and that it was already UB to pull a reference of the Context from the draw signal callback. If that isn't the case then I rescind all that.

from gtkd.

MikeWey avatar MikeWey commented on July 30, 2024

scope: News to me. I haven't seen that anywhere in the docs. I'd trust you if you said it was, though.

http://dlang.org/deprecate.html#scope for allocating classes on the stack

Context: That's what I mean; I was under the impression that the Context would be unusable outside of the draw signal call and that it was already UB to pull a reference of the Context from the draw signal callback. If that isn't the case then I rescind all that.

It's probably very uncommon but it is possible, it's possible to make it undefined behavior and destroy the d copy at the end of the callback.

from gtkd.

soltanmm avatar soltanmm commented on July 30, 2024

scope: Looks like I'm changing up my code some. >_<

Context: I meant that the Context is just a wrapper object that could be destroyed at the end of the callback, while the GtkContext C object still exists for the GTK system to use. In that sense, if GTK already has it to be UB to increase the reference count of a GtkContext in a callback, such UB would be mirrored in GtkD and negate the need for a user to have periodic GC calls. On the other hand, if GTK doesn't have UB if the user steals a reference to the GtkContext in a callback, then it makes sense to me that such behavior is mirrored in GtkD.

The gist of it: My grey area is that I don't know if it is or isn't UB in just good ole' GTK (I assumed it was, perhaps erroneously).

from gtkd.

MikeWey avatar MikeWey commented on July 30, 2024

Commit ad79895 adds an overload of addOnDraw witch accepts an delegate that uses an Scoped Context. The Scoped Context is destroyed at the end of the scope.

from gtkd.

MikeWey avatar MikeWey commented on July 30, 2024

With the 3.0.0 release the non Scoped version is marked as deprecated.

from gtkd.

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.