Hi,

I noticed that my project keeps using more and more memory, even when
it does nothing (or I thought so). I finally came to the conclusion
that remote calls causing it. 

Here is a small test: http://virtualro.cluj.astral.ro/andi/memtest/

It has a timer that keeps updating a label with
flash.system.System.totalMemory, and a button that calls a remote
method using amphp (it does nothing, only returns 1).

Now, if you start the demo, you can see that  totalMemory stays the
same, until you press the button. Then it starts to increase slowly
(the number changes in about every 6-8 secs). If you press the button
many times (=call the remote method), totalMemory increase is more
accentuate. 

What is causing that, how could I avoid it? Something is wrong here.

Thanks.



Here's the code of my test:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="vertical"
        xmlns:ns1="*"
        xmlns:control="control.*"
        initialize="initTimer()"
        width="200" height="200">
        
        <mx:RemoteObject 
                destination="amfphp"
        
endpoint="http://virtualro.cluj.astral.ro/virtualro/adminBackend/gateway-modules_amfphp1_9beta2.php";
                id="testService"
                source="TestService"
                showBusyCursor="true"
                result="onResult( event )"
                fault="onFault( event )">
        </mx:RemoteObject>
        
        <mx:Script>
                <![CDATA[
                        import mx.controls.Alert;
                        
                        [Bindable]
                public var totmem:Number = 0;
                
                //timer for watching memory usage 
                public function initTimer():void {
                    var myTimer:Timer = new Timer(1000, 0);
                    myTimer.addEventListener("timer", timerHandler);
                    myTimer.start();
                }
                public function timerHandler(event:TimerEvent):void {
                    totmem = flash.system.System.totalMemory;
                }
        
                // remote call handlers
                        public function onResult( event : * = null ) : void {
                                trace("TestService::onResult " + event.result);
                        }
                        public function onFault( event : * = null ) : void {
                                trace("TestService::onFault ");
                                Alert.show("TestService has failed");
                        }
                

                ]]>
        </mx:Script>
        <mx:Label text="totalMemory: {totmem}"/>
        <mx:Button label="Call Service" click="{testService.callTest();}"/>
</mx:Application> 

Reply via email to