1 Reply Latest reply on May 17, 2007 5:22 AM by Newsgroup_User

    Memory leak in LoadVars?


      In one of our apps, we've a need to continuously load new data (using Loadvars) every x seconds from the server. However, I seem to be having a memory leak issue when doing the same. Consider the following skeletal code:

      var myVars:LoadVars = new LoadVars();
      myVars.onHTTPStatus = function(httpStatus) {
      this.httpStatus = httpStatus;
      myVars.onLoad = function(success:Boolean){
      //trace("Data loaded: " + success);
      var int:Number = setInterval(loadData,2000);
      function loadData(){
      myVars.load(" http://server/RealTime/ISv3.asp?UpperLimit=100&lowerLimit=0");

      Here, I'm loading the data from an ASP page every 2 seconds in the same LoadVars object. Now, when I run this movie continuosly for a few hours, there's a huge increase in memory usage of this movie. Using the profiler, I've made sure that the memory is increasing for the Flash movie and not InetInfo or any other process/thread.

      Now, here we do not have anything else in the movie (no visuals, no calculations etc.) and more over we're re-using the same LoadVars object to reload data. Any pointers as to what we could be doing wrong? Any help would be greatly appreciated.
        • 1. Re: Memory leak in LoadVars?
          Level 7
          You might try setting it up with two LoadVars and using sendAndLoad. And
          also you have no guarantee your call has finished before your trying again.
          You could use a simple boolean to only call the asp after the prior call has

          var mySender:LoadVars = new LoadVars();
          var myReceiver:LoadVars = new LoadVars();
          var doneLoading = true;

          mySender.onHTTPStatus = function(httpStatus) {
          this.httpStatus = httpStatus;

          myReceiver.onLoad = function(success:Boolean){
          doneLoading = true;
          //trace("Data loaded: " + success);

          function loadData(){
          doneLoading = false;
          mySender.upperLimit = 100;
          mySender.lowerLimit = 0;
          mySender.sendAndLoad(" http://server/RealTime/ISv3.asp", myReceiver);

          var int:Number = setInterval(loadData, 2000);


          Dave -
          Head Developer
          Adobe Community Expert