-
Notifications
You must be signed in to change notification settings - Fork 13
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
GC is eating my widgets #105
Comments
Aha! Solvable by maintaining a separate Surely this is just a hacky workaround...? |
I've now also learned it is important to call GC manually once after destroying windows: window.destroy
GC.collect
window = nil If I don't do this, the GC runs at a later point in time, tries to run
with The same necessity applies to widgets: window.destroy
widgets.each &.destroy
GC.collect
window = nil
widgets = nil
GC.collect Just a few more crashes to solve... |
It worked with GTK4 bindings. require "gtk4"
app = Gtk::Application.new("hello.example.com", Gio::ApplicationFlags::None)
app.activate_signal.connect do
window = Gtk::ApplicationWindow.new(app)
fixed = Gtk::Fixed.new
50.times do |i|
20.times do |j|
btn = Gtk::Button.new label: i.to_s+"/"+j.to_s
fixed.put btn, i*10, j*10
end
end
window.child = fixed
window.present
end
exit(app.run) |
Interesting, thanks. This speaks in favor of the approach taken by your GI Crystal shard 👍 I can't really use Gtk 4 though, as I need cross-distro binaries with as much long-lasting compatibility as possible (issue). I'd probably do it if I could statically link gtk4 somehow Edit: I've now switched from this shard to https://github.com/phil294/gtk3.cr instead where I am facing less issues |
Hello,
consider this demo code which simply adds 100 buttons:
Expected:
Actual:
Bug only appears with GC active (default).
In this case, GC starts killing off widgets every ~130 widget additions or so. This bug can also appear much faster, however. I am building AHK_X11, AutoHotkey for Linux, a scripting language. When I translate the above Crystal code into AHK, widgets are disappearing even after 3-20 widgets have been placed. I will add a demo code snippet + GIF below. Its internals aren't important I assume (because there is a lot of other stuff going on too in the background which probably affects GC behavior), I only want to show this to somewhat prove the severity of this bug: It definitely occurs with only a few buttons as well.
Same behavior with CheckButtons. Did not observe such behavior with ComboBoxes or Labels.
Did not investigate much further than all of this. I will gladly provide more input as needed, however. Any idea on how to at least circumvent this bug (other than
-Dgc_none
, of course) would be much appreciated, as this is kind of a blocker for me now.On a related note, I am seeing a few different GLib null pointers (exceptions) and invalid memory access errors (process abort) then and again. For example, the above GIF window crashed (it always does at some point). Those appear seemlingly random, so I guess they are GC-related too, but I haven't tested this yet, and it's not a show stopper. I also cannot use
malloc_pthread_shim
because I am using-Dpreview_mt
which does not seem to work together. Might need to open up new issue(s) at some point.Thank you once again for all your work on this!
The text was updated successfully, but these errors were encountered: