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

Key: LPP-5213
Type: Bug Bug
Status: Resolved Resolved
Resolution: Duplicate
Priority: -- --
Assignee: P T Withington
Reporter: Philip Romanik
Votes: 0
Watchers: 0
Operations

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

Memory is leaking when <class> is defined

Created: 07/Dec/07 09:54 AM   Updated: 08/Dec/07 02:57 AM
Component/s: LFC - Object System
Affects Version/s: RingDing (4.1)
Fix Version/s: None

Time Tracking:
Not Specified

Environment: swf and dhtml.

Severity: Blocker
Runtime: N/A
Fix in hand: False


 Description  « Hide
I simplified a recent problem into a simple app that shows a memory leak. In the following example, if you remove the <class> tag the leak goes away. There are several small leaks that I will post as a separate jira task.

On my system I see heap leakage of 15-20 megs for creating 100 windows.


<canvas>

  <!-- Note: I'm not even instantiating myWindow -->
  <!-- Remove this line to stop the leak -->
  <class name="myWindow" extends="window"/>

  <view>
    <simplelayout axis="x" spacing="10"/>

    <button text="Open/Close windows (leaks)" >
      <attribute name="counter" type="number" value="0"/>

      <method name="test">
        var win = new lz.window(canvas,{title:'new', resizable:true, closeable:true});
        win.open();
        win.close();
        win.destroy();
        delete win;
      </method>

      <handler name="onclick">
        <![CDATA[
          for (var i = 0; i < 100; i++) {
            this.test();
            this.counter++;
            Debug.write(this.counter);
          }
        ]]>
      </handler>
    </button>

  </view>
</canvas>


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
P T Withington - 07/Dec/07 08:26 PM
I think you are being fooled. Without the class declaration, the window component is not loaded and you are not actually instantiating any windows. When I delete the class declaration, I get:

ERROR @lpp-5213.lzx#14: call to undefined method 'window'
ERROR @lpp-5213.lzx#15: undefined object does not have a property 'open'
ERROR @lpp-5213.lzx#16: undefined object does not have a property 'close'
ERROR @lpp-5213.lzx#17: undefined object does not have a property 'destroy'



P T Withington - 08/Dec/07 02:57 AM
I'm running this in swf with debugging turned on.

The deal is, components are only (auto) included if the compiler can detect their use (by scanning the LZX). The compiler cannot guess that you are dynamically instantiating lz.window, so when you leave out the <class> tag, there is no lz.window to instantiate. With the class tag in, the compiler sees that you are depending on window (to extend it), so auto-includes it.

You can confirm this by replacing your <class> tag with <window/>, which will also cause the window code to be auto-included. If you include the <window/> tag, you see the leak, if you don't you don't see the leak. So, in that sense this bug is a dup of LPP-5217 (which I will submit a fix for shortly).