Opened 14 years ago

Closed 13 years ago

#2461 closed defect (fixed)

Destroy Dialog does not clean up all references to the dialog elements and the memory for those elements is not freed

Reported by: [email protected] Owned by: bill
Priority: high Milestone: 1.2
Component: Dijit Version: 0.4.1
Keywords: Cc: [email protected]…, [email protected]
Blocked By: Blocking:

Description (last modified by jfcunat)

When i create a dialog programatically and then destroy it, references to the dialog nodes are not cleared and the nodes keep occupying memory.

To check if the nodes are getting freed i am using sIeve.

The dojo version is 0.4.1

Below is a sample test case which is a simplified version of the dojo test_Dialog_createWidget.html 1.) Open the page in sIeve 2.) In sIeve, do 'clear in use' nodes and click on the 'Show Dialog Link' 3.) Now,do 'show in use' nodes to see the nodes created by the dialog. 4.) Click on the 'hide dialog' link and see some nodes getting freed but not all.

Shouldn't all the dialog nodes be freed and reclaim memory ?



<html> <head> <title>Dialog Widget Dojo Tests</title> <script type="text/javascript" src="../../dojo.js"></script> <script type="text/javascript">



<script type="text/javascript"> function init() {

var dlgProg = dojo.widget.createWidget("dojo:Dialog",{id:'testDialog', toggle:"fade",toggleDuration:250,bgOpacity:0}, dojo.byId("dialogNode"));;


</script> <style type="text/css"> body { font-family : sans-serif; } .dojoDialog {

background : #eee; border : 1px solid #999; -moz-border-radius : 5px; padding : 4px;


form {

margin-bottom : 0;

} </style> </head> <body> <a href="javascript:init()">Show Dialog</a>&nbsp;&nbsp;&nbsp; <a href="javascript:dojo.widget.byId('testDialog').destroy()">Hide Dialog</a> <div id="dialogNode">

<p>Testing Dialog Memory Leak!</p>

</div> </body> </html>

Thanks, Adish

Change History (10)

comment:1 Changed 14 years ago by [email protected]

Similarly for a TabContainer?, if i close a tab in a tab container, not all nodes related to the tab are freed.Below is a test case. 1.) Open the file in sIeve, click 'show in use' nodes

  1. ) Close the tab, see that not all nodes are freed.Like the titleNode span,

close Image span, innerDiv div are not freed and still have a reference. 3.) If you destroy the titleNode node using dojo.dom.destroyNode(this.titleNode) and then this.titleNode = null, the node will be freed.But the same will not work for this.closeButtonNode (closeImage) as it have an dojoAttachEvent. I have seen this in a lot of places, where ever there is an dojoAttachPoint, i need to destroy the node manually and if there is an dojoAttachEvent, the node reference is not cleared even after manually destroying.

<meta http-equiv="Context-Type" content="text/html; charset=UTF-8"> <html xmlns="" xml:lang="en" lang="en"> <head> <title>TabContainer? Demo</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta> <script type="text/javascript" src="../../dojo.js"></script> <script type="text/javascript">

dojo.require("dojo.widget.TabContainer?"); dojo.require("dojo.widget.ContentPane?");


<style type="text/css"> body {

font-family : sans-serif;


.dojoTabPane {

padding : 10px 10px 10px 10px; overflow: auto;

} </style> </head>



<div id="ttabs" dojoType="TabContainer?" labelPosition="top" style="width: 100%; height: 10em;">

<div id="ttab1" dojoType="ContentPane?" label="Tab 1" closable="true"> <h1>I am tab 1</h1> </div>


</body> </html>

Thanks, Adish

comment:2 Changed 14 years ago by alex


comment:3 Changed 14 years ago by bill

Component: WidgetsDijit
Milestone: 0.91.0
Owner: changed from bill to koranteng

comment:4 Changed 13 years ago by bill

Owner: changed from koranteng to bill

comment:5 Changed 13 years ago by bill

Milestone: 1.02.0

comment:6 Changed 13 years ago by bill

Note that in version >= 0.9 you need to call destroyRecursive() not destroy().

comment:7 Changed 13 years ago by alex

Milestone: 2.01.3

Milestone 2.0 deleted

comment:8 in reply to:  6 Changed 13 years ago by jfcunat

Cc: [email protected] [email protected] added
Description: modified (diff)

Replying to bill:

Note that in version >= 0.9 you need to call destroyRecursive() not destroy().

I have found a reason of the memory leak for in 1.1 and current version of dojo. A destroy of the this._moveable (dojo.dnd.TimedMoveable?) has to be done in the destroy of the Dialog.

Just add (this._moveable.destroy()) and the memory leak disappears.


JF Cunat

comment:9 Changed 13 years ago by bill

Milestone: 1.31.2
Status: newassigned

Ah simple fix, thanks for finding that.

comment:10 Changed 13 years ago by bill

Resolution: fixed
Status: assignedclosed

(In [13748]) Fix leak. Fixes #2461. !strict

Note: See TracTickets for help on using tickets.