- Previous thread: qooxdoo-devel - Table changeVisibility events
- Next thread: qooxdoo-devel - List selection and form controller
- Threads sorted by date: javascript 201007
I have a "best practices" question.
I have created several composite objects that have member widgets. For the
the "sub-widgets" I create I use member object references that I make sure
to destruct. However, I realized after trying to track down a memory leak I
was causing with a List and ListItems I'm adding that I see lots of
information about missing destructs. I thought I was being a good citizen
and disposing the things I create. Here are example messages:
$$user-toolTip' in qx.ui.form.SelectBox[undefined]:
qx.ui.tooltip.ToolTip[911]
Native.js (line 61)
111480 Missing destruct definition for '$$user-toolTip' in
qx.ui.basic.Label[undefined]: qx.ui.tooltip.ToolTip[911]
Native.js (line 61)
111486 Missing destruct definition for '$$user-group' in
qx.ui.form.RadioButton[undefined]: qx.ui.form.RadioGroup[893]
Native.js (line 61)
111489 Missing destruct definition for '$$user-group' in
qx.ui.form.RadioButton[undefined]: qx.ui.form.RadioGroup[893]
Native.js (line 61)
111492 Missing destruct definition for '$$user-toolTip' in
qx.ui.form.RadioButtonGroup[undefined]: qx.ui.tooltip.ToolTip[875]
Native.js (line 61)
111495 Missing destruct definition for '$$user-toolTip' in
qx.ui.basic.Label[undefined]: qx.ui.tooltip.ToolTip[875]
Native.js (line 61)
111511 Missing destruct definition for '$$user-toolTip' in
qx.ui.form.SelectBox[undefined]: qx.ui.tooltip.ToolTip[805]
Native.js (line 61)
Here is an example of the type of Composite I am creating:
qx.Class.define("mdvr.AudioConfigPanel",
{
extend : qx.ui.container.Composite,
construct : function()
{
this.base(arguments);
this.-groupBox = new qx.ui.groupbox.GroupBox("Audio");
this.setLayout(new qx.ui.layout.VBox());
this.add(this.-groupBox);
// Sub widgets
this.-panelObjs = []; // Initialize array that will hold non-critical
widgets for later disposal
var grid = new qx.ui.layout.Grid(8,8);
this.-panelObjs.push(grid);
this.-groupBox.setLayout(grid);
this.-groupBox.setPadding(10);
// Subwidget 1
var tooltip = new qx.ui.tooltip.ToolTip("Here's a tooltip.");
tooltip.set({width: 200, rich: true});
this.-panelObjs.push(tooltip);
var label = new qx.ui.basic.Label("A Label");
this.-panelObjs.push(label);
label.setToolTip(tooltip);
this.-groupBox.add(label, {row: 0, column: 0});
// Subwidget 2
...
},
members :
{
-groupBox : null,
-panelObjs : null, // Array to track other qooxdoo objects that we create
for later disposal
...
},
destruct : function()
{
this.-disposeObjects("-groupBox", "-anotherSubWidget");
this.-disposeArray("-panelObjs");
}
}
I was able to eliminate the destruct warnings for items I create, but I'm
not sure what's the right best practice for making sure things get removed.
I didn't necessarily want to extend a widget for what I'm doing as my
composites aren't very complex. What should I be doing?
Hi ,
there shouldn't occur any warnings for attributes with a prefix "$$".
This is a bug, see:
http://bugzilla.qooxdoo.org/show-bug.cgi?id867
Cheers,
Chris
Am 22.07.2010 16:52, schrieb arnis-andy:
there shouldn't occur any warnings for attributes with a prefix "$$".
This is a bug, see:
http://bugzilla.qooxdoo.org/show-bug.cgi?id867
Cheers,
Chris
Am 22.07.2010 16:52, schrieb arnis-andy:
Is it even necessary for me to dispose of qx objects that are contained by
other qx objects. For example if I do something in my constructor like:
var groupBox = new.ui.groupbox.GroupBox("Stuff");
this.setLayout(new qx.ui.layout.VBox());
this.add(groupBox);
do I need to set references to the groupBox and layout and manually dispose
of them? Or, will qx take care of cleaning them up?
Hi,
the answer depends on your use case. qooxdoo has no garbage collection
or some think like this. qooxdoo dispose only qooxdoo objects on
shutdown (triggered from the unload event).
So if you have a class, which is used the complete application runtime,
it it not so important to keep the references for a manually dispose.
But otherwise you will get memory leaks, because the instances are
disposed only on shutdown.
Cheers,
Chris
Am 23.07.2010 15:10, schrieb arnis-andy:
the answer depends on your use case. qooxdoo has no garbage collection
or some think like this. qooxdoo dispose only qooxdoo objects on
shutdown (triggered from the unload event).
So if you have a class, which is used the complete application runtime,
it it not so important to keep the references for a manually dispose.
But otherwise you will get memory leaks, because the instances are
disposed only on shutdown.
Cheers,
Chris
Am 23.07.2010 15:10, schrieb arnis-andy:
Thank you. That was what I needed to know. I have several "extend :
qx.ui.container.Composite" type objects that I will be creating and
destroying many times throughout the lifetime of the application. From
what you said it implies I need to make sure to clean up all the objects.
For objects that extend qx.ui.core.Widget and that implement
-createChildControlImpl and -add to add their sub widgets/objects, do these
also need to clean up after themselves, or does the Widget object take care
of disposing it's own children. I couldn't quite be sure from perusing the
code.
Thanks for the feedback!
yes, that's right.
The qx.ui.core.Widget takes care, you don't need to dispose these
objects manually.
Related Threads
- moving keyboard model configuration UI - kde
- [xwiki-devs] section editing in wiki/2.0 - xwiki
- Bonanza - kernel
- [Samba] samba server version removal - samba
- form and hidden input with user id - django
- Linux-2.6.31-rc4 - shut the annoying "failed to acquire vblank..." - kernel
- [eGroupWare-developers] Aleksandar Kalev is out of the office. - egroupware
- Atomic counters with nginx - nginx