Hi ! I’m french I speak a little english, so i write what i can
I have a problem with garbage collector and NetConnection. I can’t delete NetConnection object of memory and my website become heavy!
I do a test for show you, my problem :
private var myService:NetConnection
//--------------------------------------------------------------------------------------
//---------------------------------------------------------------Fonction - constructeur
//--------------------------------------------------------------------------------------
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
//--------------------------------------------------------------------------------------
//------------------------------------------------------------------------Initialisation
//--------------------------------------------------------------------------------------
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
//-------------------------------------------------------
stage.addEventListener( MouseEvent.MOUSE_DOWN, onStage_Down )
stage.addEventListener( MouseEvent.MOUSE_UP, onStage_Up )
}
//--------------------------------------------------------------------------------------
//---------------------------------Au mouseDown sur le stage, on lance la boucle de test
//--------------------------------------------------------------------------------------
private function onStage_Down(e:MouseEvent):void
{
stage.addEventListener( Event.ENTER_FRAME, onLoop )
}
//--------------------------------------------------------------------------------------
//------------------------------------------------Au mouseUp on stoppe la boucle de test
//--------------------------------------------------------------------------------------
private function onStage_Up(e:MouseEvent):void
{
stage.removeEventListener( Event.ENTER_FRAME, onLoop )
}
//--------------------------------------------------------------------------------------
//------------------------------Pendant la boucle, on déclenche le garbage collector et on recréer
//--------------------------------------------------------------------------------------
private function onLoop(e:Event):void
{
myService = null
System.gc();
//-------------------------------------------------------
myService = new NetConnection()
myService.connect("http://localhost/Remoting/amfphp/gateway.php")
myService.close()
myService = null;
//-------------------------------------------------------
trace( System.totalMemory );
}
I use NetConnection with amfphp in my website.
How its’t possible the Sytem.memory grow up indefinitly?
Thans for answers with no complicated words