Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In gobject_move_ref, replace weak reference with strong reference in gc_preserve_glib #89

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jwahlstrand
Copy link
Member

This prevents these objects, which are "subclasses" such as GtkCanvas, from being garbage collected. Previously, the code was supposed to intercept the garbage collection and do this "weak to strong" conversion if the object survives being unreferenced by Julia, but #87 seems to indicate a problem. This is a band-aid fix for that issue.

@nHackel @tknopp this seems to fix #87. I will look at consequences in Gtk4Makie and other downstream packages before merging.

This "fix" will probably prevent GtkCanvas and other subclasses that use gobject_move_ref from ever being freed. A better fix will have to wait for someone to do a deep dive into the GObject <-> Julia object code.

…n `gc_preserve_glib`

This prevents these objects, which are "subclasses" such as GtkCanvas, from being garbage
collected at all. Previously, the code was supposed to intercept the garbage collection
and do this "weak to strong" conversion if the object survives being unreferenced by
Julia, but #87 seems to indicate a problem.
This is a band-aid fix for that issue.
@nHackel
Copy link
Contributor

nHackel commented Mar 24, 2025

This does not stop the CairoSurface from being collected right? As long as those can still be gc'ed, the memory leak shouldn't be too bad (at least for our use case where we don't dynamically create new canvases and only load the UI once per session ideally)

@jwahlstrand
Copy link
Member Author

As far as I know the surface should still be GC'd. I'll verify that though. If the widget leak is an issue it might be possible to purposely destroy widgets by deleting them from gc_preserve_glib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SEGFAULT and/or SEGABRT with GtkCanvas
2 participants