J
Justice
Currently I'm doing some experimenting with the XMLHTTP object in
Javascript. Now,
the XMLHttp object is asynchronous (at least in this case), and the
following code causes a significant memory loss even though I seem to be
allocaitng everything; help would be *vastly* appreciated. What am I doing
wrong here? I thought I was doing everything correctly (setting things to
null, for example) but none of the memory seems to get replaced. I've been
experiencing allocations of memory up to 125 megabytes (!) that simply
persist in the browser, never to go away...
Thanks in advance for any help you can provide!
ASyncQueue = new Array();
-Justice
function DataHandlerLookupLoop(value, id, numberOfLoops)
{
for (var loopCount = 0; loopCount < numberOfLoops; loopCount++)
{
DataHandlerLookup(loopCount,loopCount,id);
}
}
function DataHandlerLookup(value, number, id)
{
++asyncsRunning;
AsyncQueue.push(new Object());
AsyncQueue[number].ThisElement = document.getElementById(id);
AsyncQueue[number].Server = new ActiveXObject("Msxml2.XMLHTTP");
AsyncQueue[number].Server.onreadystatechange = f;
AsyncQueue[number].Server.open("GET",
"http://localhost/MyCompany/data.metadata?text=" + value, true);
AsyncQueue[number].Server.send(value);
}
function f()
{
var temporaryLength = AsyncQueue.length;
for (var index = 0; index < AsyncQueue.length; ++index)
{
if (AsyncQueue[index] != null)
{
if (AsyncQueue[index].Server.readyState == FINISHED)
{
AsyncQueue[index].Server.abort();
AsyncQueue[index].Server = null;
delete AsyncQueue[index].Server;
AsyncQueue[index].ThisElement = null;
delete AsyncQueue[index].ThisElement;
AsyncQueue[index] = null;
--asyncsRunning;
}
if (asyncsRunning == 0)
{
var tempQueueLength = AsyncQueue.length;
for (var ix = 0; ix < tempQueueLength; ++ix)
{
AsyncQueue.pop();
}
CollectGarbage();
}
}
Javascript. Now,
the XMLHttp object is asynchronous (at least in this case), and the
following code causes a significant memory loss even though I seem to be
allocaitng everything; help would be *vastly* appreciated. What am I doing
wrong here? I thought I was doing everything correctly (setting things to
null, for example) but none of the memory seems to get replaced. I've been
experiencing allocations of memory up to 125 megabytes (!) that simply
persist in the browser, never to go away...
Thanks in advance for any help you can provide!
ASyncQueue = new Array();
-Justice
function DataHandlerLookupLoop(value, id, numberOfLoops)
{
for (var loopCount = 0; loopCount < numberOfLoops; loopCount++)
{
DataHandlerLookup(loopCount,loopCount,id);
}
}
function DataHandlerLookup(value, number, id)
{
++asyncsRunning;
AsyncQueue.push(new Object());
AsyncQueue[number].ThisElement = document.getElementById(id);
AsyncQueue[number].Server = new ActiveXObject("Msxml2.XMLHTTP");
AsyncQueue[number].Server.onreadystatechange = f;
AsyncQueue[number].Server.open("GET",
"http://localhost/MyCompany/data.metadata?text=" + value, true);
AsyncQueue[number].Server.send(value);
}
function f()
{
var temporaryLength = AsyncQueue.length;
for (var index = 0; index < AsyncQueue.length; ++index)
{
if (AsyncQueue[index] != null)
{
if (AsyncQueue[index].Server.readyState == FINISHED)
{
AsyncQueue[index].Server.abort();
AsyncQueue[index].Server = null;
delete AsyncQueue[index].Server;
AsyncQueue[index].ThisElement = null;
delete AsyncQueue[index].ThisElement;
AsyncQueue[index] = null;
--asyncsRunning;
}
if (asyncsRunning == 0)
{
var tempQueueLength = AsyncQueue.length;
for (var ix = 0; ix < tempQueueLength; ++ix)
{
AsyncQueue.pop();
}
CollectGarbage();
}
}