Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Why does a closed NetConnection that has no event listeners or references stick around in memory?

New Here ,
Apr 16, 2013 Apr 16, 2013

It seems that if flash.net.NetConnection is instantiated and connected to an HTTP URL (such as an AMFPHP gateway), that instance is never picked up by garbage collection even after it has been closed and the only reference is set to null.

On the other hand, if the instance is connected to null (as would be done when used to play video/mp3 files), the instance is cleared from memory.

To clarify, the following connection will stick around in memory:

var stickyConn:NetConnection = new NetConnection();
stickyConn
.connect("http://myserver/amfphp/gateway.php");
stickyConn
.close(); stickyConn = null;

Whereas, the following connection will be cleared from memory immediately:

var tempConn:NetConnection = new NetConnection();
tempConn
.connect(null);

tempConn.close();

tempConn = null;

Some things I have already tried to solve this issue:

  • set the client to an empty object (since the default value of the client is the NetConnection itself)
  • before closing the connection, call connect(null)
  • after closing the connection, call connect(null) and close it again

Has anyone run into this issue before? Is there a solution to this?

TOPICS
ActionScript
426
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 16, 2013 Apr 16, 2013

1. are you defining a netstream?

2. how do you know stickyConn is not cleared from memory?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 16, 2013 Apr 16, 2013
LATEST

I am not defining a NetStream, as it is not necessary for AMFPHP communication.

I know for a fact that stickyConn is not cleared from memory because I am using a profiler that shows me how many objects of each type are still in memory (and I am able to view where/when each instance was instantiated)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines