• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Flex strings never cleared from the memory

New Here ,
Dec 20, 2013 Dec 20, 2013

Copy link to clipboard


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();

   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++){
       log += rawArray-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 = 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){
     }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 = rawArray[k+j+tempIdx];
      //leftOverMessageNotify = new ByteArray();
     //leftOverMessageNotify = rawArray;
     for(var i:int = 0 ; i<rawArray.length ; i++){
      leftOverMessageNotify = rawArray;
     rawArray = null;

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







Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines