HtmlDialog and ObjectSpace

for SU’s own extensions, HtmlDialogs appear to be garbage collected on close…

for others, including the Github examples, they are not…

what is the best practice to avoid all these zombi dialogs…

john

When you say SU’s own extensions, which one are you referring to? I think DC still use WebDialogs.

yes, DC’s are still WebDialogs that reuse a single dialog for each…

ObjectSpace.each_object(UI::WebDialog){|dlg| p dlg}
#<UI::WebDialog:0x007fd92a16a1b0 @last_width=345, @last_height=560>
#<UI::WebDialog:0x007fd92d11bd50 @last_width=400, @last_height=600>

and on closer inspection, it appears the others that use CEF [Exrension Manager, Extension Warehouse, 3d Warehouse, Instructor] aren’t using ruby to generate them…

The main reason for the query:

I was checking a couple of my own extensions to make sure I was re-using single dialogs…

One of them is re-used hundreds of times so I wrap it and call a constant…

NODLG = UI::HtmlDialog.new unless defined? NODLG

to check if others are also behaving I used…

ObjectSpace.each_object(UI::HtmlDialog){|dlg| dlg.show}

and every previous one I had tested from the GitHub examples re-appeared on screen…

I adjusted the code so that each now only uses one dialog, but I curious if others even bother about this issue…

john

It’ll be the same as with any other object, making sure that there aren’t anything holding on to any references to the dialogs.

With SKUI I was investigating this quite a bit, and it was easy to create circular references with callbacks etc. I don’t recall the exact details, but I think I left comments in the source.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.