Debugging memory leak in Flex 3.5

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Debugging memory leak in Flex 3.5

Paul Stearns
I started down this path some time ago, when I ran into a dead end and other projects piled up, I needed to abandon the hunt for memory leaks in my application. I am now 100% focused on solving this as it has gotten to be a real problem.

I use FlexBuilder 3 as a tool. I am not opposed to using other tools. Where I am right now;

1) I made a copy of my application and am working with one module (moduleLoader) and the main application.
2) The application is basically a shell with a menu bar, when a user selects a menu item it finds an existing moduleloader, and loads the .swf file using the moduleloader.
3) When the user clicks the "X" on the panel within the moduleloader it unloads the module.
4) After the module unloads all of its children seem to stay in memory, and never go away.

At the moment The profiler has stopped functioning with the folloowing error;

java.io.IOException: Unknown 'agent -> profiler' command: 60   at com.adobe.flash.profiler.internal.ProtocolHandler.process(ProtocolHandler.java:134)   at com.adobe.flash.profiler.internal.PlayerSession.run(PlayerSession.java:383)   at java.lang.Thread.run(Unknown Source)

I need help fixing that and/or finding another memory profiler. I would like to have the profiler use a relatively current version of the Flash VM.

My current strategy is to strip things out until the problem goes away.


Reply | Threaded
Open this post in threaded view
|

Re: Debugging memory leak in Flex 3.5

Alex Harui-2
Paul,

In step 3, when they click the X and ModuleLoader unloads the module, do you see the module unload in the debugger player?  I think you would see a line like [UnloadSWF] in the debugger console.

In step 4, are the "children" you refer to the child UI widgets of the module?

One technique you could try is to add code that starts removing the children from their parents after the module is loaded.  Then you might find that removing one particular child causes the problem.  Make sure Timers and event listeners have been managed properly.

HTH,
-Alex

On 1/30/19, 11:18 AM, "Paul Stearns" <[hidden email]> wrote:

    I started down this path some time ago, when I ran into a dead end and other projects piled up, I needed to abandon the hunt for memory leaks in my application. I am now 100% focused on solving this as it has gotten to be a real problem.
   
    I use FlexBuilder 3 as a tool. I am not opposed to using other tools. Where I am right now;
   
    1) I made a copy of my application and am working with one module (moduleLoader) and the main application.
    2) The application is basically a shell with a menu bar, when a user selects a menu item it finds an existing moduleloader, and loads the .swf file using the moduleloader.
    3) When the user clicks the "X" on the panel within the moduleloader it unloads the module.
    4) After the module unloads all of its children seem to stay in memory, and never go away.
   
    At the moment The profiler has stopped functioning with the folloowing error;
   
    java.io.IOException: Unknown 'agent -> profiler' command: 60   at com.adobe.flash.profiler.internal.ProtocolHandler.process(ProtocolHandler.java:134)   at com.adobe.flash.profiler.internal.PlayerSession.run(PlayerSession.java:383)   at java.lang.Thread.run(Unknown Source)
   
    I need help fixing that and/or finding another memory profiler. I would like to have the profiler use a relatively current version of the Flash VM.
   
    My current strategy is to strip things out until the problem goes away.
   
   
   

Reply | Threaded
Open this post in threaded view
|

Re: Debugging memory leak in Flex 3.5

Paul Stearns
In reply to this post by Paul Stearns
Alex:

I have a group of 10 <mx:ModuleLoader objects defined in my mxml. I reuse these objects for each of the modules I load. A user can have no more than 10 "panels/modules" open at any one time.

By way of example;

I load a module called TNMEmployee into ModuleLoader module0, this module contains all of the widgets needed to do CRUD on the employee table. I then click the "X" to exit the module. It in turn calls some housekeeping and "unloads the module". When I load my next module, it will reuse module0 used previously. If module0 is in use it grabs the next moduleloader module1.

The memory profiler seems to work in my "live" development project.

What I see there is the Instances (count) of the widgets used by TMEmployee, does not go down and the Memory (not cumulative) does not go down. The Instance & memory of TMEmployee increases each time I close & open it again.

One area I believe is problematic is my netconnections which I use frequently in all modules to talk to the middle tier. An example looks like; (RemotingConnection extends NetConnection)

Call;
   var netConn:RemotingConnection = new RemotingConnection();   netConn.connect(RootDomain + "Gateway.aspx");   CursorManager.setBusyCursor();   netConn.call("ACE.Security.getDatabase", new Responder(getDatabaseResults));

Handler;

private function getDatabaseResults(strResult:String):void
{   CursorManager.removeBusyCursor();   txtDatabase.text = strResult;
}

----------------------------------------
From: Alex Harui <[hidden email]>
Sent: 1/30/19 3:31 PM
To: "[hidden email]" <[hidden email]>, "[hidden email]" <[hidden email]>
Subject: Re: Debugging memory leak in Flex 3.5
Paul,

In step 3, when they click the X and ModuleLoader unloads the module, do you see the module unload in the debugger player? I think you would see a line like [UnloadSWF] in the debugger console.

In step 4, are the "children" you refer to the child UI widgets of the module?

One technique you could try is to add code that starts removing the children from their parents after the module is loaded. Then you might find that removing one particular child causes the problem. Make sure Timers and event listeners have been managed properly.

HTH,
-Alex

On 1/30/19, 11:18 AM, "Paul Stearns" wrote:

I started down this path some time ago, when I ran into a dead end and other projects piled up, I needed to abandon the hunt for memory leaks in my application. I am now 100% focused on solving this as it has gotten to be a real problem.

I use FlexBuilder 3 as a tool. I am not opposed to using other tools. Where I am right now;

1) I made a copy of my application and am working with one module (moduleLoader) and the main application.
2) The application is basically a shell with a menu bar, when a user selects a menu item it finds an existing moduleloader, and loads the .swf file using the moduleloader.
3) When the user clicks the "X" on the panel within the moduleloader it unloads the module.
4) After the module unloads all of its children seem to stay in memory, and never go away.

At the moment The profiler has stopped functioning with the folloowing error;

java.io.IOException: Unknown 'agent -> profiler' command: 60 at com.adobe.flash.profiler.internal.ProtocolHandler.process(ProtocolHandler.java:134) at com.adobe.flash.profiler.internal.PlayerSession.run(PlayerSession.java:383) at java.lang.Thread.run(Unknown Source)

I need help fixing that and/or finding another memory profiler. I would like to have the profiler use a relatively current version of the Flash VM.

My current strategy is to strip things out until the problem goes away.


Reply | Threaded
Open this post in threaded view
|

Re: Debugging memory leak in Flex 3.5

Alex Harui-2
Are you calling close() on the NetConnection?

Are there animations in the module?  Or timers?

Is the instance count on RemoteConnection and Responders also going up?

Commenting out code can sometimes help you find the problem.  Comment out the NetConnection.call and see if that allows the module to unload.

HTH,
-Alex

On 1/30/19, 1:12 PM, "Paul Stearns" <[hidden email]> wrote:

    Alex:
   
    I have a group of 10 <mx:ModuleLoader objects defined in my mxml. I reuse these objects for each of the modules I load. A user can have no more than 10 "panels/modules" open at any one time.
   
    By way of example;
   
    I load a module called TNMEmployee into ModuleLoader module0, this module contains all of the widgets needed to do CRUD on the employee table. I then click the "X" to exit the module. It in turn calls some housekeeping and "unloads the module". When I load my next module, it will reuse module0 used previously. If module0 is in use it grabs the next moduleloader module1.
   
    The memory profiler seems to work in my "live" development project.
   
    What I see there is the Instances (count) of the widgets used by TMEmployee, does not go down and the Memory (not cumulative) does not go down. The Instance & memory of TMEmployee increases each time I close & open it again.
   
    One area I believe is problematic is my netconnections which I use frequently in all modules to talk to the middle tier. An example looks like; (RemotingConnection extends NetConnection)
   
    Call;
       var netConn:RemotingConnection = new RemotingConnection();   netConn.connect(RootDomain + "Gateway.aspx");   CursorManager.setBusyCursor();   netConn.call("ACE.Security.getDatabase", new Responder(getDatabaseResults));
   
    Handler;
   
    private function getDatabaseResults(strResult:String):void
    {   CursorManager.removeBusyCursor();   txtDatabase.text = strResult;
    }
   
    ----------------------------------------
    From: Alex Harui <[hidden email]>
    Sent: 1/30/19 3:31 PM
    To: "[hidden email]" <[hidden email]>, "[hidden email]" <[hidden email]>
    Subject: Re: Debugging memory leak in Flex 3.5
    Paul,
   
    In step 3, when they click the X and ModuleLoader unloads the module, do you see the module unload in the debugger player? I think you would see a line like [UnloadSWF] in the debugger console.
   
    In step 4, are the "children" you refer to the child UI widgets of the module?
   
    One technique you could try is to add code that starts removing the children from their parents after the module is loaded. Then you might find that removing one particular child causes the problem. Make sure Timers and event listeners have been managed properly.
   
    HTH,
    -Alex
   
    On 1/30/19, 11:18 AM, "Paul Stearns" wrote:
   
    I started down this path some time ago, when I ran into a dead end and other projects piled up, I needed to abandon the hunt for memory leaks in my application. I am now 100% focused on solving this as it has gotten to be a real problem.
   
    I use FlexBuilder 3 as a tool. I am not opposed to using other tools. Where I am right now;
   
    1) I made a copy of my application and am working with one module (moduleLoader) and the main application.
    2) The application is basically a shell with a menu bar, when a user selects a menu item it finds an existing moduleloader, and loads the .swf file using the moduleloader.
    3) When the user clicks the "X" on the panel within the moduleloader it unloads the module.
    4) After the module unloads all of its children seem to stay in memory, and never go away.
   
    At the moment The profiler has stopped functioning with the folloowing error;
   
    java.io.IOException: Unknown 'agent -> profiler' command: 60 at com.adobe.flash.profiler.internal.ProtocolHandler.process(ProtocolHandler.java:134) at com.adobe.flash.profiler.internal.PlayerSession.run(PlayerSession.java:383) at java.lang.Thread.run(Unknown Source)
   
    I need help fixing that and/or finding another memory profiler. I would like to have the profiler use a relatively current version of the Flash VM.
   
    My current strategy is to strip things out until the problem goes away.