Hi Martin,
Thanks for the pointers. I found "qx.util.DisposeUtil.disposeTriggeredBy" in
the framework which solves my problem of leaking tooltips, fonts etcetera.
Using the disposerDebug version I found many other things so my code is much
better now!
While looking at objects not being disposed (using debuglevel 3 the objects are
logged to the debug window) I also found a few leaks in the V1.4.1 Qooxdoo core
code which might interest you. They all involve the TreeVirtual control:
Column model:
Because I configured nothing specific qx.ui.table.columnmodel.Resize is used as
the column model. By default no behaviour is set, so in the init() method the
following is executed:
this.setBehavior(new qx.ui.table.columnmodel.resizebehavior.Default());
This behaviour is however never freed. I introduced a member "__privBehaviour"
to store the result of "qx.ui.table.columnmodel.resizebehavior.Default()" to
dispose it in the destructor.
TreeVirtual.js
In the constructor several objects are created when no "custom" data is
provided (which I don't). They are used a little further along the way. The
following thing are leaked using this mechanism:
- The table model, which I fixed by introducing a destructor and calling
this.getTableModel().dispose();
- The data row renderer which I fixed by storing the current model
before call "this.setDataRowRenderer" and disposing the stored current model
after the call
- The data cell renderers which I fixed by iterating the currently set
renderers (tcm.getDataCellRenderer(i)) and disposing them before the loop with
statement "tcm.setDataCellRenderer(i, i == treeCol ? stdcr : ddcr);"
- The defaultDataCellRenderer because I only have one column which
becomes the "treeCol" so only the treeDataCellRenderer is used. I added a
detection for this and when defaultDataCellRenderer or treeDataCellRenderer is
not set to any of the columns I dispose this object as well.
Can you please indicate if these are indeed issues in the core code or if I am
not using the framework correctly?
Thanks in advance.
Best regards,
Jeroen
From: Martin Wittemann [mailto:[email protected]]
Sent: Tuesday, May 29, 2012 8:05 AM
To: qooxdoo Development
Subject: Re: [qooxdoo-devel] Memory leak detection
Hey,
I am currently looking into some memory leak reports and I am finding the
"qx.disposerDebugLevel" very useful.
It is in deed.
When looking at the reporting of objects not being disposed (in Object.js,
"Missing destruct definition for...") I see several issues about objects in the
Qooxdoo framework (I am using V1.4.1):
053884 Missing destruct definition for '$$user_behavior' in
qx.ui.table.columnmodel.Resize[undefined]:
qx.ui.table.columnmodel.resizebehavior.Default[503]
053885 Missing destruct definition for '$$user_selectionModel' in
qx.ui.treevirtual.SelectionManager[undefined]:
qx.ui.table.selection.Model[undefined]
053892 Missing destruct definition for '$$user_dataRowRenderer' in
webgui.ui.tree.ComtecTree[undefined]:
webgui.ui.tree.ComtecTreeRowRenderer[undefined]
053892 Missing destruct definition for '$$user_selectionModel' in
webgui.ui.tree.ComtecTree[undefined]: qx.ui.table.selection.Model[undefined]
053893 Missing destruct definition for '$$user_tableModel' in
webgui.ui.tree.ComtecTree[undefined]: qx.ui.treevirtual.SimpleTreeDataModel[482]
053893 Missing destruct definition for '$$user_metaColumnCounts' in
webgui.ui.tree.ComtecTree[undefined]: 1
053902 Missing destruct definition for '$$user_decorator' in
qx.ui.core.Widget[undefined]: qx.ui.decoration.Background[458]
056719 Missing destruct definition for '$$user_tablePaneModel' in
qx.ui.table.pane.Scroller[undefined]: qx.ui.table.pane.Model[undefined]
056723 Missing destruct definition for '$$user_menu' in
qx.ui.table.columnmenu.Button[undefined]: qx.ui.menu.Menu[616]
056729 Missing destruct definition for '$$user_opener' in
qx.ui.menu.Menu[undefined]: qx.ui.table.columnmenu.Button[undefined]
065634 Missing destruct definition for '$$user_toolTip' in
qx.ui.toolbar.Button[undefined]: qx.ui.tooltip.ToolTip[473]
Most seem to have to do with classes I derive from, like "qx.ui.table.Table",
and where I use the construction with the "custom" argument to call the
base-constructor with overrides for the tablePane, selectionModel etcetera. Is
there something I should do in the dispose of my own objects? I was expecting
code like in "qx.ui.table.Table._applySelectionModel" to dispose any selection
model if a new one is set.
No, the framework should take care of the necessary stuff itself. If thats not
the case, feel free to open up a bug report for it. :)
The problem here is, that we can only detect if there is still an object at a
given reference and thats it. This is more a "this might need to be removed"
than a "this has to be removed". Memory leak detection is unfortunately not as
easy due to the really good garbage collection in the browsers. There is no
problem if one objects references another if both don't have a connection to
the global or current scope or to the DOM. As you can guess, thats impossible
to detect by an algorithm. ;)
Futhermore I have a lot of buttons with a tooltip set using "someWidget.
setToolTip(new qx.ui.tooltip.ToolTip("some text"))" and I didn't expect having
to dispose them myself. I hope you can tell me how I can fix these issues (if
necessary that is).
The framework code usually uses the guidline that the one creating the obejct
is responsible for its disposing. As you are the one creating it, you have to
dispose it. Think about a situation where you build your own shared tool tip
and don't want someone else to dispose your shared tool tip.
As the tooltip derives from qx.core.Object, you should dispose it. Otherwise,
the tooltips will stay in memory due to the reference to the global scope via
the object registry.
To do so, you could either sore a reference to the tooltip and dipose it on
widget dispose or use the getToolTip function before disposing. If you are
having that a lot, it might be a good candidate to write a helper for that.
I hope that helped a bit,
Martin
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel