4 Replies Latest reply on Feb 13, 2007 11:16 PM by jpwrunyan

    HTTPService Memory Leak?

    FlightGuy Level 1
      I have an application that uses HTTPService to poll status on my server for changes. I've noticed that if I leave the client running indefinitely it eventually hangs my machine. Here is a simplified mxml application that demonstrates the problem. If I run this, either from IE 5.5 or from Firefox 2.0, and observe memory usage, it consumes between 8 and 16 kilobytes a second indefinitely.



      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="setupTimer()">
      <mx:Script>
      <![CDATA[
      private function setupTimer():void{
      // Set up a timer to tick every second
      var myTimer:Timer = new Timer(1000);
      myTimer.addEventListener(TimerEvent.TIMER, timerHandler);

      myTimer.start();
      }

      private function timerHandler(event:TimerEvent):void{
      leakyService.cancel();
      leakyService.clearResult();
      leakyService.send();
      }
      ]]>
      </mx:Script>
      <mx:HTTPService id="leakyService" url=" http://www.google.com" resultFormat="text" result="trace('Result received');"/>
      </mx:Application>



      I've tried creating the HTTPService in ActionScript, both as an instance variable (equivalent to this MXML example), and also as a local variable, so I'm creating a new HTTPService instance for each invocation. All gives the same result. Is there something I'm missing that I should be clearing up after each iteration? Anybody else encountered this problem?

      PS. Sorry I can't make it format the code properly, but you get the idea...