kg_bang
asked on
Memory leak in httpservice or urlrequest in Adobe AIR
Hello,
I am having troubles with some major memory leaks in an AIR application i wrote. The application is doing several hundreds of http requests using the httpservice component and based on the profiler (and my task manager memory monitor) I can tell that the memory keeps growing and there is a clear correlation between the size of the response and the amount of memory being leaked...
It is important to note that if i have multiple calls to the same page, the memory does not grow so it sounds almost like there is some kind of an hidden caching mechanism or something.
I tried using URLRequest but got almost the same result.
Please take a look at the code and let me know if you can help.
Thanks,
KG
I am having troubles with some major memory leaks in an AIR application i wrote. The application is doing several hundreds of http requests using the httpservice component and based on the profiler (and my task manager memory monitor) I can tell that the memory keeps growing and there is a clear correlation between the size of the response and the amount of memory being leaked...
It is important to note that if i have multiple calls to the same page, the memory does not grow so it sounds almost like there is some kind of an hidden caching mechanism or something.
I tried using URLRequest but got almost the same result.
Please take a look at the code and let me know if you can help.
Thanks,
KG
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
import flash.utils.setTimeout;
public function init():void {
setTimeout(call, 3000);
}
private var pages:Array = new Array("http://www.experts-exchange.com", "http://www.adobe.com", "http://www.cnn.com", "http://www.bbc.co.uk", "http://www.cnet.com", "http://www.google.com", "http://www.msn.com", "http://www.yahoo.com", "http://www.yahoo.co.uk", "http://www.msnbc.com");
private var request:HTTPService
private var counter:int = 0;
public function call():void {
request = new HTTPService();
request.method = "GET";
request.useProxy = false;
request.headers = {"User-Agent":"-", Referer:"-"}
request.resultFormat = "text";
request.addEventListener(ResultEvent.RESULT, done);
request.url = pages[counter];
request.send();
}
public function done(_event:Event):void {
request.disconnect();
request = null;
// calling the garbage collector
try
{
var lc1:LocalConnection = new LocalConnection();
var lc2:LocalConnection = new LocalConnection();
lc1.connect( "gcConnection" );
lc2.connect( "gcConnection" );
}
catch (e:Error) {}
counter += 1;
if (counter >= 10) return;
init();
}
]]>
</mx:Script>
</mx:WindowedApplication>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
ASKER
I found several posts about this problem but no one actually came up with a solution for that. I just cannot believe there is no solution for that... I tried so many ways but every time I see the same result, every call raises the amount of memory in use by my application and does not free it until application termination.