We have been struggling with this issue for quite a bit of time. Hope that we could get some help here.
we are building a peer-to-peer application for video by using rtmfp. Peers connect to other online peers by creating NetStream, and send/receive byte data through NetStream.
What we found was, after trying to connect cetain number of peers(200 for instance; it is not the number of simutaneous connections but the total attempts over the time), the code runs very slow on NetStream constructor and NetStream.close(). The data is collected by Adobe Scout CC, where we found that in many cases even creating one NetStream object exceeds the frame time, as well as closing one NetStream.
It looks that it is doing very complex initialization and cleanup work in NetStream for p2p connections, and the amount of work is related to the total NetStream objects which had been created.
Is this a known issue? Any way to work around it? Any help would be highly appreciated.
this is probably a bug in Flash Player doing something horrible (like O(N^2)) and not cleaning up closed NetStreams.
after closing the NetStreams, are you sure you've also disconnected it from any cameras/microphones or Video objects, removed all event listeners, and otherwise have no references to them, so they can be garbage collected? NetStreams that have not been garbage collected may still be on a NetConnection's list of NetStreams that probably gets scanned (probably in O(N^2) or O(N^3)) whenever you make a new one.
regardless, making new NetStreams shouldn't use that much CPU. i encourage you to open a bug against Flash Player.