Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json Flex字符串从未从内存中清除-->;它最终被清除了_Json_String_Apache Flex_Memory_Memory Leaks - Fatal编程技术网

Json Flex字符串从未从内存中清除-->;它最终被清除了

Json Flex字符串从未从内存中清除-->;它最终被清除了,json,string,apache-flex,memory,memory-leaks,Json,String,Apache Flex,Memory,Memory Leaks,我有一段时间遇到了这个奇怪的问题,并试图解决它,在网上寻找合适的解决方案,但我仍然不知所措 当我使用flex profiler(4.6)检查我的应用程序的内存使用情况时,字符串的部分不断增加,最终达到崩溃点 我从应用程序的源代码中指出了这种增加的地方 它是我传递给Json.decode()的本地字符串变量。它从来没有清除。 我从套接字服务器获得的json字符串的所有实例都保留在内存中,直到应用程序崩溃,即使探查器说该字符串有0个路径 我不知道如何清除这些字符串。它只会继续增长 请帮帮我。我已经为

我有一段时间遇到了这个奇怪的问题,并试图解决它,在网上寻找合适的解决方案,但我仍然不知所措

当我使用flex profiler(4.6)检查我的应用程序的内存使用情况时,字符串的部分不断增加,最终达到崩溃点

我从应用程序的源代码中指出了这种增加的地方

它是我传递给Json.decode()的本地字符串变量。它从来没有清除。 我从套接字服务器获得的json字符串的所有实例都保留在内存中,直到应用程序崩溃,即使探查器说该字符串有0个路径

我不知道如何清除这些字符串。它只会继续增长

请帮帮我。我已经为此挣扎了一个星期了

提前感谢您的支持

我的源代码中我认为泄漏源的部分如下

        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;
            }
        }
受保护函数evtserverReseved(事件:ProgressEvent):无效{
var tmpArr:ByteArray=newbytearray();
var tempByteArray:ByteArray=newbytearray();
socEvtServer.readBytes(tmpArr,0,socEvtServer.bytes可用);
写入字节(leftOverMessageNotify,0,leftOverMessageNotify.length);
tempByteArray.writeBytes(tmpArr,0,tmpArr.length);
leftOverMessageNotify=new ByteArray();
帕斯比提雷(tempByteArray);
}
专用函数parseByteArray(rawArray:ByteArray):void{
if((rawArray[0]==0x30 | | rawArray[0]==0x31)&&rawArray[1]==0x00){
var log:String=“”;

对于(var i:int=0;i您尝试将“nothing”值赋给函数末尾的对象吗?感谢您的响应@matilu,我尝试了euckrString=null甚至euckrString=“”但仍然存在同样的问题。我怀疑问题更像是为什么flex gc不收集路径为0的垃圾。如果问题是gc在需要时工作,而不是试图强迫她做出决定。但是如果你什么都不留下,浪费的价值就会降低,至少。字符串最终在运行时被垃圾收集。我检查过,不知怎么的,只有Flex profiler显示这些字符串仍保留在内存中。但我不知道为什么。让我困惑的是,我发现我的应用程序中内存泄漏的原因是源代码的另一部分误用了计时器对象。不过,感谢@matilu的帮助。点击在使用探查器时经常强制GC按钮。这很有帮助。