[Question] Do GObject::Binding
s need to be unbound manually to free memory?
#176
-
Hi! This isn't technically an issue, I was just wondering whether Example: label1 = Gtk::Label.new
label2 = Gtk::Label.new
label_binding = GObject::Binding.new(source: label1, source_property: "label", target: label2, target_property: "label", flags: :bidirectional)
label1.label = "Hello!"
# label2.label is now "Hello!" as well Will the memory be freed automatically, or would I need to call Thanks in advance! <3 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, Yes, you need to disconnect it manually or memory will leak, this is because we need to store a reference to the proc we use internally, otherwise it will be garbage collected and GObject will access invalid memory and crash. However... I dislike this pattern and want to change this so I was working on a way to connect objects without the need to manually disconnect to avoid memory leaks, basic tests worked but need more tests to be ready. |
Beta Was this translation helpful? Give feedback.
Hi,
Yes, you need to disconnect it manually or memory will leak, this is because we need to store a reference to the proc we use internally, otherwise it will be garbage collected and GObject will access invalid memory and crash.
However... I dislike this pattern and want to change this so I was working on a way to connect objects without the need to manually disconnect to avoid memory leaks, basic tests worked but need more tests to be ready.