Author: ptw
Date: 2007-12-12 05:13:58 -0800 (Wed, 12 Dec 2007)
New Revision: 7518
Modified:
openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/svg/LzSprite.js
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMakeLoadSprite.as
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzMakeLoadSprite.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/services/LzIdle.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs
openlaszlo/trunk/lps/components/debugger/newcontent.lzx
openlaszlo/trunk/lps/components/debugger/scrollingtext.lzx
Log:
Change 20071209-ptw-k by [EMAIL PROTECTED] on 2007-12-09 09:32:18 EST
in /Users/ptw/OpenLaszlo/ringding-2
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Fix Sprite memory Leaks
Bugs Fixed:
LPP-5217 'windows can leak memory
Technical Reviewer: [EMAIL PROTECTED] (message://<[EMAIL PROTECTED]>)
QA Reviewer: [EMAIL PROTECTED] (message://<[EMAIL PROTECTED]>)
Doc Reviewer: (pending)
Details:
LzMakeLoadSprite.*, LzSprite.*: Eliminate recursion argument. Not
used for sprites.
LzSprite.*: In #destroy set __LZdeleted flag to prevent events
from resurrecting you. No need for recursive sprite destruction
now. Move delegate removal back to destroy from predestroy.
LzSprite.js: If parent is not being deleted, remove yourself from
your parent's childnodes array.
LzIdle: Be careful to create coi Array on instance, not prototype.
LzNode: Comment and simplify $once and $always processing. Add
comment to explain importance of __LzDeleted flag.
LaszloView: Destroy the sprite _before_ you check for a recursive
call.
LzReplicationManager: Remove superfluous call to LzSprite#destroy.
newcontent, scrollingtext: Remove unused id (that causes a leak).
Tests:
I modified Phil's test case to only create/destroy 1 window per
click. The test methodology is:
1. Start test
2. Click twice to create any shared substrate
3. Debug.markObjects()
4. Click once
5. Debug.findNewObjects()
6. Debug.whyAlive()
Result: Before change, many leaked window sprites. After change, no
leaked window sprites.
NOTE: There are still some other minor leaks that I have not
attempted to address here, but will report as a separate bug.
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.lzs 2007-12-12 05:08:04 UTC
(rev 7517)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.lzs 2007-12-12 13:13:58 UTC
(rev 7518)
@@ -1296,7 +1296,7 @@
* @access private
*/
function __LZresolveRefs ( refs ){
- //need to resolve init= before constraints...
+ // $once are applied before $always
for ( var p in refs ){
var rp = refs[ p ];
var pp;
@@ -1321,18 +1321,17 @@
}
}
this.dataBindAttribute( p , pp );
- } else if ( !('dependencies' in rp && rp.dependencies) ){
- if (rp instanceof Function) {
- rp.call(this);
- }
+ } else if ((rp instanceof Function) &&
+ // A function with no or null dependencies is a $once
+ (! ('dependencies' in rp && rp.dependencies))) {
+ rp.call(this);
}
}
- // Now resolve the $always values
+ // Functions with dependencies are $always
for ( var p in refs ){
- // The string check prevents a dhtml error
var rp = refs[ p ];
- if (rp instanceof Function && ('dependencies' in rp)) {
+ if ((rp instanceof Function) && ('dependencies' in rp)) {
this.applyConstraint( p , rp , rp.dependencies.call(this) );
}
}
@@ -1774,7 +1773,7 @@
if (this.__LZdeleted == true) {
return;
}
-
+ // To keep delegates from resurrecting us. See LzDelegate#execute
this.__LZdeleted = true;
if (this.ondestroy.ready) this.ondestroy.sendEvent( this );
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs
2007-12-12 05:08:04 UTC (rev 7517)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs
2007-12-12 13:13:58 UTC (rev 7518)
@@ -596,7 +596,6 @@
* @access private
*/
function destroyClone ( v ) {
- if (v.sprite) v.sprite.destroy(true);
v.destroy();
}
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
2007-12-12 05:08:04 UTC (rev 7517)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
2007-12-12 13:13:58 UTC (rev 7518)
@@ -231,7 +231,7 @@
}
LzInputTextSprite.prototype.__textEvent = function ( e, eventname ){
- if (this.destroyed == true) return;
+ if (this.__LZdeleted == true) return;
var keycode = e ? e.keyCode : event.keyCode;
if (eventname == 'onfocus' || eventname == 'onmousedown') {
if (eventname == 'onfocus') {
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js 2007-12-12
05:08:04 UTC (rev 7517)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js 2007-12-12
13:13:58 UTC (rev 7518)
@@ -1178,16 +1178,22 @@
LzSprite.prototype.predestroy = function() {
}
-LzSprite.prototype.destroy = function(recursive) {
- if (this.destroyed == true) return;
- //alert('destroy' + this + ', recursive ' + recursive);
- if (recursive) {
- if (this.__children) {
- for (var i = 0; i < this.__children.length; i++) {
- this.__children[i].destroy(recursive);
- }
+LzSprite.prototype.destroy = function() {
+ if (this.__LZdeleted == true) return;
+ // To keep delegates from resurrecting us. See LzDelegate#execute
+ this.__LZdeleted = true;
+
+ // Remove from parent if the parent is not going to be GC-ed
+ if (! this.__parent.__LZdeleted) {
+ var pc = this.__parent.__children;
+ for (var i = pc.length - 1; i >= 0; i--) {
+ if (pc[i] === this) {
+ pc.splice(i, 1);
+ break;
}
+ }
}
+
if (this.__ImgPool) this.__ImgPool.destroy();
if (this.__LZimg) this.__discardElement(this.__LZimg);
if (this.__LZclick) {
@@ -1217,7 +1223,6 @@
this.__discardElement(this.__LZcanvas);
}
this.__ImgPool = null;
- this.destroyed = true;
}
/**
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/svg/LzSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/svg/LzSprite.js 2007-12-12
05:08:04 UTC (rev 7517)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/svg/LzSprite.js 2007-12-12
13:13:58 UTC (rev 7518)
@@ -471,7 +471,7 @@
}
}
-LzSprite.prototype.destroy = function(recursive) {
+LzSprite.prototype.destroy = function() {
}
LzSprite.prototype.getMouse = function(xy) {
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMakeLoadSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMakeLoadSprite.as
2007-12-12 05:08:04 UTC (rev 7517)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMakeLoadSprite.as
2007-12-12 13:13:58 UTC (rev 7518)
@@ -255,7 +255,7 @@
/**
* @access private
*/
-LzMakeLoadSprite.destroy = function (recur) {
+LzMakeLoadSprite.destroy = function () {
if ('updateDel' in this)
this.updateDel.unregisterAll();
if ('errorDel' in this)
@@ -266,5 +266,5 @@
this.loader.unload( this.loader.mc );
// call shadowed destroy()
- this.___destroy( recur );
+ this.___destroy();
}
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as 2007-12-12
05:08:04 UTC (rev 7517)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as 2007-12-12
13:13:58 UTC (rev 7518)
@@ -897,7 +897,18 @@
LzSprite.prototype.predestroy = function(){
this.bringToFront();
-
+}
+
+/**
+ * This method should remove a view, its media, and any of its subviews.
+ * @access private
+ *
+ */
+LzSprite.prototype.destroy = function(){
+ if (this.__LZdeleted == true) return;
+ // To keep delegates from resurrecting us. See LzDelegate#execute
+ this.__LZdeleted = true;
+
if (this.updatePlayDel) {
this.updatePlayDel.unregisterAll();
delete this.updatePlayDel;
@@ -907,22 +918,7 @@
this.doQueuedDel.unregisterAll();
delete this.doQueuedDel;
}
-}
-/**
- * This method should remove a view, its media, and any of its subviews.
- * @access private
- *
- */
-LzSprite.prototype.destroy = function(recursive){
- if (recursive) {
- if (this.owner.subviews) {
- for (var i = 0; i < this.owner.subviews.length; i++) {
- this.owner.subviews[i].sprite.destroy(recursive);
- }
- }
- }
-
this.__LZFinishDestroyOnIdle();
}
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzMakeLoadSprite.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzMakeLoadSprite.lzs
2007-12-12 05:08:04 UTC (rev 7517)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzMakeLoadSprite.lzs
2007-12-12 13:13:58 UTC (rev 7518)
@@ -254,7 +254,7 @@
/**
* @access private
*/
-function destroy (recur) {
+function destroy () {
if ('updateDel' in this)
this.updateDel.unregisterAll();
if ('errorDel' in this)
@@ -265,7 +265,7 @@
this.loader.unload( this.loader.mc );
// call shadowed destroy()
- this.___destroy( recur );
+ this.___destroy();
}
} // End of LzMakeLoadSpriteClass
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.lzs 2007-12-12
05:08:04 UTC (rev 7517)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.lzs 2007-12-12
13:13:58 UTC (rev 7518)
@@ -900,14 +900,11 @@
* @access private
*
*/
-function destroy(recursive){
- if (recursive) {
- if (this.owner.subviews) {
- for (var i = 0; i < this.owner.subviews.length; i++) {
- this.owner.subviews[i].sprite.destroy(recursive);
- }
- }
- }
+function destroy(){
+ if (this.__LZdeleted == true) return;
+ // To keep delegates from resurrecting us. See LzDelegate#execute
+ this.__LZdeleted = true;
+
if (this.updatePlayDel) {
this.updatePlayDel.unregisterAll();
delete this.updatePlayDel;
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/services/LzIdle.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/services/LzIdle.lzs 2007-12-12
05:08:04 UTC (rev 7517)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/services/LzIdle.lzs 2007-12-12
13:13:58 UTC (rev 7518)
@@ -34,12 +34,14 @@
*/
class LzIdleClass {
-var coi = [];
+ var coi;
var removeCOI = null;
function initialize () {
-this.removeCOI = new LzDelegate( this , "removeCallIdleDelegates" );
+ // Create array on instance, not prototype
+ this.coi = new Array;
+ this.removeCOI = new LzDelegate( this , "removeCallIdleDelegates" );
}
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs 2007-12-12
05:08:04 UTC (rev 7517)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs 2007-12-12
13:13:58 UTC (rev 7518)
@@ -1157,10 +1157,10 @@
super.destroy.apply(this, arguments);
+ if (this.sprite) { this.sprite.destroy() }
+
if ( recursiveCall == true ) { return; }
- if (this.sprite) { this.sprite.destroy(true) }
-
//this.__LZFinishDestroyOnIdle();
this.setVisible ( false );
Modified: openlaszlo/trunk/lps/components/debugger/newcontent.lzx
===================================================================
--- openlaszlo/trunk/lps/components/debugger/newcontent.lzx 2007-12-12
05:08:04 UTC (rev 7517)
+++ openlaszlo/trunk/lps/components/debugger/newcontent.lzx 2007-12-12
13:13:58 UTC (rev 7518)
@@ -3,7 +3,7 @@
**************************************************************************-->
<!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
-* Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
+* Copyright 2001-2004, 2007 Laszlo Systems, Inc. All Rights Reserved.
*
* Use is subject to license terms. *
* X_LZ_COPYRIGHT_END ****************************************************** -->
@@ -281,7 +281,7 @@
<view name="lower_right_corner" bgcolor="#888888" width="11" height="11"
x="${parent.width-11}" y="${parent.height-11}"/>
- <_dbg_horiz_scrollbar id="dhsb" y="${classroot.textpane.height}"
+ <_dbg_horiz_scrollbar name="dhsb" y="${classroot.textpane.height}"
width="${parent.width - 11}"
bgcolor="#666666" height="13" />
Modified: openlaszlo/trunk/lps/components/debugger/scrollingtext.lzx
===================================================================
--- openlaszlo/trunk/lps/components/debugger/scrollingtext.lzx 2007-12-12
05:08:04 UTC (rev 7517)
+++ openlaszlo/trunk/lps/components/debugger/scrollingtext.lzx 2007-12-12
13:13:58 UTC (rev 7518)
@@ -281,7 +281,7 @@
<view name="lower_right_corner" bgcolor="#888888" width="11" height="11"
x="${parent.width-11}" y="${parent.height-11}"/>
- <_dbg_horiz_scrollbar id="dhsb" y="${parent.content.height-2}"
+ <_dbg_horiz_scrollbar name="dhsb" y="${parent.content.height-2}"
width="${parent.width - 11}"
bgcolor="#666666" height="13" />
@@ -421,7 +421,7 @@
</class>
</library>
<!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
-* Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
+* Copyright 2001-2004,2007 Laszlo Systems, Inc. All Rights Reserved. *
* Use is subject to license terms. *
* X_LZ_COPYRIGHT_END ****************************************************** -->
<!-- @LZX_VERSION@ -->
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins