Hi, I'm Francesco from Italy, and I want to post a technical help request:
I use the script above to "callback" a remote .aspx page. My site make larger use of this because I'm trying to develope a RealTime Multiplayer D&D based game, and until now everything goes well. This morning I left IE open on my chat page. When I come back after some hours, a message about "increasing system virtual memory" was displayed by OS. I saw the Task Manager and iexplore.exe process WAS USING 135 MB RAM and 458 MB SWAP file !!!!!! PANIC PANIC !! First I don't belie it was a problem about my website, but then, monitoring minutes per minutes the taskmanager with IE open in my website, I view that it was instead.
I've notice that IE increase both virtual and ram memory size as much as bigger is the data tha comes back to server response (expecially if IE is left open for a long period). now, this is my script (see above), and now I must view my personal site with Netscape or Firefox to avoid problems with memory. In facts they do not increase memory as IE, but are "normal".
How can I fix my script
--------------------------------------------------
--------------------------------------------------
function AsyncCallback(pageURL, params, args, divID)
{
//. pageURL e l'indirizzo della pagina a cui effettuare il callback
//. params e un parametro per identificare nel codice remoto l'operazione da intraprendere
//. args sono eventuali parametri da passare alla funzione remota, come testo o dati da gestire
//. divID e l'id del tag da andare ad aggiornare che supporti la proprieta innerHTML;
var pageurl = pageURL + " callback=true¶ms=" + params + "&args=" + args;
var pagediv = divID;
var xmlRequest = null;
try
{
//setto i permessi di UBR per mozilla-based browsers
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
}
catch (e)
{ /**/ }
try
{
//Mozilla Browsers
xmlRequest = new XMLHttpRequest();
}
catch (e)
{
try
{
//Internet Explorer
xmlRequest = new ActiveXObject("MSXML2.XMLHTTP");
}
catch (e)
{
try
{
xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
xmlRequest = null;
return;
}
}
}
//viene invocata una nuova richiesta di callback alla pagina
//che restituira il risultato tramite post in modo asincorono
//alleggerendo quindi il webbrowser che continuera a gestire
//le richieste dell'utente nel frattempo
xmlRequest.open("POST", pageurl, true);
//manage the asynchronous callback state
xmlRequest.onreadystatechange = function()
{
if (xmlRequest.readyState == 4)
{
//questa funzione anonima viene richiamata quando
//la richiesta la richiesta viene completata
if (xmlRequest.status == 200)
{
if (pagediv == "") return;
window.document.getElementById(pagediv).innerHTML = xmlRequest.responseText;
}
else
{
window.document.getElementById(pagediv).innerHTML = "error retrieving response from callback";
}
}
}
xmlRequest.send(null);
}

IE memory problem with my script ? or it's bigger ?
BlogusMaximus
it crashes again! I can't find out what's the problem !!!
www.legendoftherealms.it go here and view your taskmanager at iexplore.exe and watch yourself how memory (both virtual and ram) increase so much!!!!!
HELP !!
CosmicSheep
Francesco,
I am interested in your progress. Is your code stable without leak yet I have tried both GET and POST methods, and both leak.
TGP
rkcarroll
//these are counters for active request that have to get response from server
var AsyncPool = 0;
var AsyncMax = 5;
function AsyncCallback(pageURL, params, args, divID)
{
//. pageURL e l'indirizzo della pagina a cui effettuare il callback
//. params e un parametro per identificare nel codice remoto l'operazione da intraprendere
//. args sono eventuali parametri da passare alla funzione remota, come testo o dati da gestire
//. divID e l'id del tag da andare ad aggiornare che supporti la proprieta innerHTML;
if (AsyncPool > AsyncMax) return;
AsyncPool++;
var pageurl = pageURL + " callback=true¶ms=" + params + "&args=" + args;
var pagediv = divID;
var xmlRequest = null;
try
{
//setto i permessi di UBR per mozilla-based browsers
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
}
catch (e)
{ /**/ }
try
{
//Mozilla Browsers
xmlRequest = new XMLHttpRequest();
}
catch (e)
{
try
{
//Internet Explorer
xmlRequest = new ActiveXObject("MSXML2.XMLHTTP");
}
catch (e)
{
try
{
xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
xmlRequest = null;
return;
}
}
}
//viene invocata una nuova richiesta di callback alla pagina
//che restituira il risultato tramite post in modo asincorono
//alleggerendo quindi il webbrowser che continuera a gestire
//le richieste dell'utente nel frattempo
xmlRequest.open("POST", pageurl, true);
//manage the asynchronous callback state
xmlRequest.onreadystatechange = function()
{
if (xmlRequest.readyState == 4)
{
//questa funzione anonima viene richiamata quando
//la richiesta la richiesta viene completata
if (xmlRequest.status == 200)
{
if (pagediv != "")
window.document.getElementById(pagediv).innerHTML = xmlRequest.responseText;
xmlRequest = null;
AsyncPool--;
}
else
{
if (pagediv != "")
window.document.getElementById(pagediv).innerHTML = "error retrieving response from callback";
xmlRequest = null; //I think this is optional
AsyncPool--;
}
}
else
{
AsyncPool--;
if (AsyncPool < 0) AsyncPool = 0;
if (AsyncPool == 4) AsyncPool = 5; //this re-block another request if it's on waiting
}
}
xmlRequest.send( ); //note that there is not "NULL" between (..)
}
function SendCallback(pageURL, params, args)
{
//invia una richiesta e quindi non rientra nella categoria degli script Asincroni che devono
//attendere il risultato di un'operazione precedente prima di poter effettuare altre richieste
//. pageURL e l'indirizzo della pagina a cui effettuare il callback
//. params e un parametro per identificare nel codice remoto l'operazione da intraprendere
//. args sono eventuali parametri da passare alla funzione remota, come testo o dati da gestire
//. divID e l'id del tag da andare ad aggiornare che supporti la proprieta innerHTML;
var pageurl = pageURL + " callback=true¶ms=" + params + "&args=" + args;
var xmlRequest = null;
try
{
//setto i permessi di UBR per mozilla-based browsers
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
}
catch (e)
{ /**/ }
try
{
//Mozilla Browsers
xmlRequest = new XMLHttpRequest();
}
catch (e)
{
try
{
//Internet Explorer
xmlRequest = new ActiveXObject("MSXML2.XMLHTTP");
}
catch (e)
{
try
{
xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
xmlRequest = null;
return;
}
}
}
//viene invocata una nuova richiesta di callback alla pagina
//che restituira il risultato tramite post in modo asincorono
//alleggerendo quindi il webbrowser che continuera a gestire
//le richieste dell'utente nel frattempo
//this is for SEND a request
xmlRequest.open("POST", pageurl, false);
xmlRequest.send(null);
xmlRequest = null;
}
SO if you want to send a callback you have to do this with "POST" while invoking the OPEN method and set NULL between the () of SEND method; and if you want to GET a callback, you have to use the "POST" in the OPEN and don't use the NULL between the ( ) of SEND method of the request. It's all for NOW.... I will let you know if it's REALLY stable
FRANCESCO
Javafun
Drakx
xmlRequest.onreadystatechange = function()
{
if (xmlRequest.readyState == 4)
{
//questa funzione anonima viene richiamata quando
//la richiesta la richiesta viene completata
if (xmlRequest.status == 200)
{
if (pagediv == "") return;
window.document.getElementById(pagediv).innerHTML = xmlRequest.responseText;
}
else
{
window.document.getElementById(pagediv).innerHTML = "error retrieving response from callback";
}
xmlRequest = null; <<<<< -- this is the code to release the object memory but doesn't solve my problem!
}
}
John Colaizzi
When the connection has a lot of request a callback request spend more time to come back from server. So in that time I have not to perform any request! If I continue to callback server, I will fill the activeX pool.. and crash my memory!
I now added a global variable that counts "asynccallback" functions call that still have to receive response from server. Until this number is < "value" then I can invoke a new callback, else I must wait for an old request to become complete!!
Ran-Solo
Just use a "get" request instead of a "post" request for the XmlHttp.Open(..) method ! the memory is now safe also for an intense use of the script!!!
Bytheway, I did not understand why with POST request the memory increase so much.
Can anyone say something about it
-------------------------------------------------
mm, not at all.... I tried again with POST and now it's all ok... bah.
I don't understand...