Quantcast
Channel: Adobe Community : Discussion List - Using Flash Builder
Viewing all articles
Browse latest Browse all 1802

Flex strings never cleared from the memory

$
0
0

I have this weird problem for a while and try to solve it to look up on the net for proper solution but still I am clueless.

When I check my application's memory usage with flex profiler (4.6) the portion of String keep increasing and eventually reach the point of crash.

And I pin pointed where this increasing occurs from my application's source code.

It is the local string variable that I passed to Json.decode(). It never cleared.
All the instance of the json string that I got from the socket server remains in the memory til app crashes even if profiler says there is 0 path to the String.

I don't know how to clear these Strings. It only keeps growing.

Please help me. I have been struggled with this for a week now.

Thanks for any support in advance.

![enter image description here][1]

portion of my source code that I think the source of the leak is as following.


//////////////////////
   protected function evtserverReseved(event:ProgressEvent):void{
 
      var tmpArr:ByteArray = new ByteArray();
    var tempByteArray:ByteArray = new ByteArray();
    socEvtServer.readBytes(tmpArr, 0, socEvtServer.bytesAvailable);

     tempByteArray.writeBytes(leftOverMessageNotify, 0, leftOverMessageNotify.length);
    tempByteArray.writeBytes(tmpArr, 0, tmpArr.length);

    leftOverMessageNotify = new ByteArray();
    parseByteArray(tempByteArray); 
   }

   private function parseByteArray(rawArray:ByteArray):void{
    if(( rawArray[0] == 0x30 || rawArray[0] == 0x31 ) && rawArray[1] == 0x00 ){
     var log:String = "";
     for(var i:int=0; i<16; i++){
      if(rawArray[i]==0){
      }else{
       log += rawArray[i]-48;
      }
     }
    
     sizeOfFullListNotify = uint(log);
     commonFunction.printLog("Event Server eventNotify sizeOfFullListNotify=" + sizeOfFullListNotify);
     rawArray.position = 16;
    }
   
    var tempIdx:uint = rawArray.position;
    var tempLength:uint = rawArray.length;

    if(sizeOfFullListNotify <= tempLength - tempIdx){
     var tempArray:ByteArray = new ByteArray();
     var tempLeftOver:ByteArray = new ByteArray();
     var j:uint;
     for(j=0; j <sizeOfFullListNotify ; j++){
      tempArray[j] = rawArray[j+tempIdx];
     }
     var euckrString:Object = tempArray.readMultiByte( tempArray.length,"euc-kr").replace(" ","").replace("\n","");
    
     //commonFunction.printLog("Total memory=" + flash.system.System.totalMemory +", Free memory=" + flash.system.System.freeMemory + ", Event Server eventNotify JSON 수신 data size=" +euckrString.toString().length+ ", body=" + euckrString.toString() );

      var ob:Object = com.adobe.serialization.json.JSON.decode(euckrString.toString());
    
     commonFunction.printLog("Total memory=" + flash.system.System.totalMemory +", Free memory=" + flash.system.System.freeMemory + ", Event Server eventNotify JSON data size=" +euckrString.length+ ", body=" + euckrString );
    
       if(ob.method != null){
      //gridBox.DT_HOUSE.addItemAt(ob,0);
      gridBox.DT_HOUSE.push(ob);
     
      totlaReceivedList++;
     }else if(!(ob.result is String)){
      //confirm for registerEventNotify
      commonFunction.printLog("confirm for registerEventNotify");
     }         
     if(sizeOfFullListNotify < tempLength - tempIdx){
      for(var k:uint=0; k <tempLength-tempIdx-sizeOfFullListNotify ; k++){
       tempLeftOver[k] = rawArray[k+j+tempIdx];
      }
      parseByteArray(tempLeftOver);
     }else{
      //leftOverMessageNotify = new ByteArray();
     }
    }else{
     //leftOverMessageNotify = rawArray;
     for(var i:int = 0 ; i<rawArray.length ; i++){
      leftOverMessageNotify[i] = rawArray[i];
     }
     rawArray = null;
    }
   }
/////////////////////

var euckrString:Object(String) is the portion that never cleared from the memory.
It keeps stacking till crashes.

 

sc1.PNG


Viewing all articles
Browse latest Browse all 1802

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>