Opened 15 years ago
Closed 14 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: | 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 )
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. http://home.wanadoo.nl/jsrosman/
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 ?
<!DOCTYPE HTML PUBLIC "-W3CDTD HTML 4.01EN"
<html> <head> <title>Dialog Widget Dojo Tests</title> <script type="text/javascript" src="../../dojo.js"></script> <script type="text/javascript">
dojo.require("dojo.widget.Dialog");
</script>
<script type="text/javascript"> function init() {
var dlgProg = dojo.widget.createWidget("dojo:Dialog",{id:'testDialog', toggle:"fade",toggleDuration:250,bgOpacity:0}, dojo.byId("dialogNode")); dlgProg.show();
}
</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> <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 15 years ago by
comment:2 Changed 15 years ago by
Milestone: | 0.4.2 → 0.9 |
---|
comment:3 Changed 15 years ago by
Component: | Widgets → Dijit |
---|---|
Milestone: | 0.9 → 1.0 |
Owner: | changed from bill to koranteng |
comment:4 Changed 15 years ago by
Owner: | changed from koranteng to bill |
---|
comment:5 Changed 15 years ago by
Milestone: | 1.0 → 2.0 |
---|
comment:6 follow-up: 8 Changed 15 years ago by
Note that in version >= 0.9 you need to call destroyRecursive() not destroy().
comment:8 Changed 14 years ago by
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.
Regards,
JF Cunat
comment:9 Changed 14 years ago by
Milestone: | 1.3 → 1.2 |
---|---|
Status: | new → assigned |
Ah simple fix, thanks for finding that.
comment:10 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
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
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="http://www.w3.org/1999/xhtml" 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">
</script>
<style type="text/css"> body {
}
.dojoTabPane {
} </style> </head>
<body>
</body> </html>
Thanks, Adish