This content has been marked as final. Show 3 replies
What happens if you don't delete and rebuild the socket, but just close it and then connect again? Does it reconnect that way? I remember having some troubles with XMLSocket, but don't know anymore if it was similar...
Maybe it isn't such a good idea to recreate the socket in such a short interval. What about using the onClose event to determine when the connection is closed, and only then reconnect the socket? This should be way more ressource friendly, although I'm not sure if the onClose will trigger when the connection isn't closed by the remote socket, but broken otherwise. Maybe you can give it a try.
BTW, the Flash Player 9 is already released, so you can try and see if it behaves the same. Just go to the download page to get it. I found this tool quite helpful for dealing with different Flash Player versions: FlashPluginSwitcher.
We had a discussion about XML connections eating up resources a while ago, there seemed to be no remedy other than drastically reducing the number of times a new Socket is being produced. In particular deleting the socket was definitely not freeing the memory.
What I do understand is that you need very regular polling. What I don't understand is why you need to close and open the connection on each one of those. Wouldn't it be better to employ some sort of protocol, in which you send a message to the other side and wait with a certain timeout for a response. Only if this response doesn't come in time do you re-open the connection.
But then I don't know of course how accessible "the other side" is to you.
the problem is that you use the setInterval() function. That is known to cuase a leak if you don't close it properly or keep calling it. The documentation for setInterval will tell you this as well.