473,396 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Ajax Memory Leak

Hi All,

I have a web application that calls an AjaxMethod every 1min based on a javascript timer. It appears that every time I call this ajax method, IE uses more memory.

My function goes like..

Expand|Select|Wrap|Line Numbers
  1. function ajaxFunction()  {  
  2.  
  3.    var xmlHttp;
  4.    xmlHttp = new XMLHttpRequest();
  5.    xmlHttp.open("GET","./currentActivityReport.do?action=RefreshCurrentActivity&"+parameter,true);
  6.    xmlHttp.onreadystatechange=function()  {
  7.  
  8.     if(xmlHttp.readyState==4) {
  9.  
  10.              var myspan = document.getElementById('myspan'); 
  11.              var table  = document.getElementById("Table");
  12.          myspan.removeChild(table);
  13.          table = null;
  14.              var newspan = document.createElement('span');
  15.              newspan.setAttribute("id","Table");
  16.          myspan.appendChild(newspan);                
  17.              document.getElementById("Table").innerHTML=xmlHttp.responseText;
  18.          xmlHttp.onreadystatechange=function() {};
  19.          xmlHttp.abort();
  20.          }    
  21.     }
  22.  
  23.     xmlHttp.send(""); 
  24. }
If any knows about the problem please let me know..
Sep 6 '07 #1
3 1711
acoder
16,027 Expert Mod 8TB
Please use code tags when posting code.

On line 23, change
Expand|Select|Wrap|Line Numbers
  1. xmlHttp.send("");
to
Expand|Select|Wrap|Line Numbers
  1. xmlHttp.send(null);
Sep 7 '07 #2
The innerHTML is over writting html and not releasing it from memory. You will have to look for alternatives to innerHTML.

A JavaScript framework such as the MochiKit is free and can handle your ajax requests for you and resolve all browser incompatabilies.

I have not done this myself yet; so I cannot help you any further.
Nov 10 '07 #3
Hi All,

I have a web application that calls an AjaxMethod every 1min based on a javascript timer. It appears that every time I call this ajax method, IE uses more memory.

My function goes like..
Expand|Select|Wrap|Line Numbers
  1. function ajaxFunction()  {  
  2.  
  3.    var xmlHttp;
  4.    xmlHttp = new XMLHttpRequest();
  5.    xmlHttp.open("GET","./currentActivityReport.do?action=RefreshCurrentActivity&"+parameter,true);
  6.    xmlHttp.onreadystatechange=function()  {
  7.  
  8.     if(xmlHttp.readyState==4) {
  9.  
  10.              var myspan = document.getElementById('myspan'); 
  11.              var table  = document.getElementById("Table");
  12.          myspan.removeChild(table);
  13.          table = null;
  14.              var newspan = document.createElement('span');
  15.              newspan.setAttribute("id","Table");
  16.          myspan.appendChild(newspan);                
  17.  
  18.          xmlHttp.onreadystatechange=function() {document.getElementById("Table").innerHTML=xmlHttp.responseText;
  19. };
  20.          xmlHttp.abort();
  21.          }    
  22.     }
  23.  
  24.     xmlHttp.send(""); 
  25. }
check ur code now...................and even if u r getting an error/problem then pur ur table in the function of xmlhttp.readystatechange()

try..it and reply me if my tips would become helpful to u.............
Mar 28 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: ranjeet.gupta | last post by:
Dear All Is the Root Cause of the Memory corruption is the Memory leak, ?? suppose If in the code there is Memory leak, Do this may lead to the Memory Corruption while executing the program ? ...
17
by: José Joye | last post by:
Hi, I have implemented a Service that is responsible for getting messages from a MS MQ located on a remote machine. I'm getting memory leak from time to time (???). In some situation, it is...
20
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex...
23
by: James | last post by:
The following code will create memory leaks!!! using System; using System.Diagnostics; using System.Data; using System.Data.SqlClient; namespace MemoryLeak
6
by: petermichaux | last post by:
Hi, Reading the Yahoo! UI AJAX library, there is a unique workaround for an apparent IE 6 memory leak with binding a function to onreadystatechange. Instead of binding a function to...
9
by: CeyloR | last post by:
Hello everyone, I have a problem with my Ajax page. I'm jusing prototype-1.4.0.js as framework. I have a function to populate three listboxes. The items in the listboxes are from a MYSQL...
3
by: HarryA | last post by:
Hello all, what would be a good book or article to learn AJAX with HTML/CSS/javascript on the client side and Perl on the server side? I am NOT interested in XML, PHP, CGI:: AJAX or other...
8
by: BillE | last post by:
I have an existing asp.net 2.0 webforms app using master/content pages, and it works fine. I added some Ajax elements, including some UpdatePanels and modal PopUp panels which contain asp.net...
7
by: =?Utf-8?B?Tmlrb2xheSBFdnNlZXY=?= | last post by:
Hi! I know this topic has been discussed a long way, but I haven't found any apparent solution (maybe I shouldn't be looking for a one :)) I have a very simple application with one page and with...
22
by: Peter | last post by:
I am using VS2008. I have a Windows Service application which creates Crystal Reports. This is a multi theaded application which can run several reports at one time. My problem - there is a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.