Question

I'm facing with a memory leak in my Flex application. The Flex application is part of a big web application (with all kinds of technologies inside).

The memory leak occurs when the Flex app invokes a refresh polling from the server every 5 sec.

The facts are:

  • I'm using AMFChannel to make the connection. Polling is false. Each refresh creates new AMFChannel instance.
  • Server side is BlazeDS, running as a servlet inside my web application.
  • The memory leak occurs on IE and FireFox. It not occurs at all on Chrome.
  • Over one night the IE memory increase in hundreds of MBs and eventually is crashing.
  • In the Flex, the memory do increase but much slower. Over night it will increase in 30MB.
  • Using the Flex profiler I saw that the increased memory is related to the AMFChannels.
  • I tried to set AMFChannel requestTimeout to 60 sec. It did nothing.
  • I tried to set BlazeDS connect-timeout-seconds to 60 sec. Nothing changed. But I'm not sure I did it correctly.

My conclusions till now are:

  • The AMFChannel is actually gets a connections from the browser. In Flex the AMFChannel consuming small piece of memory, while in the browser it consume much more. This explain the different in the memory consuming between the Flex app and the IE.
  • Somehow, the AMFChannel is not shutdown and not garbage collected.

My requests:

  • Is my conclusions are right?
  • How to make sure the AMFChannel is shutdown and cleaned up?
  • Is the connection instance on the client is controlled by the BlazeDS (on the server side)?
  • Any other clue to help me continue investigating this issue

Thanks

Was it helpful?

Solution

We also have the same problem. The JVM goes out of memory every 24 - 50hrs. I have documented a working fix for the problem on the JVM side.

Fixing blazeds memory leak

OTHER TIPS

Like all objects, at some point pointers need to be declared null to make it eligible for GC. With the AMFChannel object, your best method to this is to setup listeners for both the channelDisconnect and the channelFault events. Provided you have a class member reference to the instance, from either of these event handlers, you declare it null.

To determine if you should call disconnect from the client side, you can look at the properties of: shouldBeConnected and connected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top