History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-5149
Type: Bug Bug
Status: Resolved Resolved
Resolution: Duplicate
Priority: -- --
Assignee: Max Carlson
Reporter: Emilio Jose Mena Cebrian
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

Pontential Huge Memory Leak (swf): LzView and LzSprite desturction

Created: 26/Nov/07 12:53 AM   Updated: 16/Dec/07 06:04 AM
Component/s: Components - all, Laszlo Foundation Classes (LFC)
Affects Version/s: 4.0.6/Jujube
Fix Version/s: None

Time Tracking:
Not Specified

Environment: SWF 9, OL 4.0.6 (Compiling to swf8)

Severity: Critical
Runtime: N/A
Fix in hand: True


 Description  « Hide
LzView's recursive Sprite destruction is not working.

When a LzView is destroyed using destroy() method, it unregister itself from parent's subviews array.

After that, it calls to super.destroy() --LZNode.destroy()-- and then LzView.destroy(true) is called for each subnode.

When children's destructor is called whith recursiveCall == true, the LzSprite.destroy() method is not called for child.sprite
causing a Memory and resource Leaks (Sprite movieclip's aren't removed).

The original LzView method has the following code:

...
super.destroy.apply(this, arguments);

if ( recursiveCall == true ) { return; }
            if (this.sprite) { this.sprite.destroy(recursiveCall) }
...

I think it must be:


...
super.destroy.apply(this, arguments);

            if (this.sprite) { this.sprite.destroy(recursiveCall) }
if ( recursiveCall == true ) { return; }
...

I don't know if there is some collateral effects of calling LzSprite.destroy(true) for each subview
(we must remember the recursive call to child.destroy(true) in LzNode). Probably, there is a exponential number of calls to sprite.destroy()).
(a call for each subnode and a call to LzSprite.destroy(true) for each subview found in the node hierarchy iteration)

To prevent that exponential number of calls, clearing each subview' sprite addingthe following code will suffice


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);
               //ADDED CODE BEGIN
               this.owner.subviews[i].sprite = null ;
               //ADDED CODE END
            }
        }
    }

But i'm not sure about it and i haven't tested.

At least the LzView Patch works (it doesn't crash Flash)




 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
André Bargull - 27/Nov/07 10:51 AM
I've also spotted this when I worked on LPP-4879.
What I did was to restore "destroy" in SWF-runtime, so it'd work like in OL3.x times: Only the top-most MovieClip gets destroyed by "__LZFinishDestroyOnIdle".

P T Withington - 16/Dec/07 06:04 AM
Duplicate of LPP-5217