Memory leak in IE MS < 9
Posted: Fri Jun 20, 2014 3:56 am
My resolution of the virtual memory leak when use agent dashboard in IE MS < 9
Example vici:
- Code: Select all
var xmlhttp=ms_getxmlobj();
ms_ajax_send(xmlhttp,method,url,data);
if(xmlhttp)
{
xmlhttp.onreadystatechange = function()
{
if(xmlhttp != null)
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
//var response = xmlhttp.responseText
xmlhttp = null;
}
}
}
}
function ms_getxmlobj()
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function ms_ajax_send(xmlhttp,method,url,data)
{
xmlhttp.open(method,url);
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(data);
}
Example vici:
- Code: Select all
function alert_control(taskalert)
{
alert_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=AlertControl&format=text&stage=" + taskalert;
var xmlhttp=ms_getxmlobj();
ms_ajax_send(xmlhttp,'POST','manager_send.php',alert_query);
if(xmlhttp)
{
xmlhttp.onreadystatechange = function()
{
if(xmlhttp != null)
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
if (taskalert=='ON')
{
alert_enabled = 'ON';
document.getElementById("AgentAlertSpan").innerHTML = "<a href=\"#\" onclick=\"alert_control('OFF');return false;\"><? echo $lang->get("Alert is ON"); ?></a>";
}else{
alert_enabled = 'OFF';
document.getElementById("AgentAlertSpan").innerHTML = "<a href=\"#\" onclick=\"alert_control('ON');return false;\"><? echo $lang->get("Alert is OFF"); ?></a>";
}
xmlhttp = null;
}
}
}
}
}