473,804 Members | 3,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ajax Memory Leak

2 New Member
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 1738
acoder
16,027 Recognized Expert Moderator MVP
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
baudSmoke
1 New Member
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
mrkrunal
1 New Member
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.readyst atechange()

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
3417
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 ? In nut shell, what is/are the realtion/s between the Memory Leak and Memory Corruption. Juts Theoritical Assumtion below:
17
4819
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 easier to reproduce (e.g.: remote machine not available). After about 1 day, I get a usage of 300MB of memory. I have used .NET Memory Profiler tool to try to see where the leak is located. For all the leaky instances, I can see the following (I...
20
8122
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 matches are called within a loop (like if or for). E.g. for(int i = 0; i < 10; i++) { Regex r = new Regex();
23
4577
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
2245
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 onreadystatechange, the library polls the readystate of the request object until it becomes 4. Then it calls the handler function. This polling seems like a lot of work but maybe is a good approach? If bad then what is better? Another person asked about this...
9
1709
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 database and are related. The items are requested by a php page.
3
1422
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 'tools' that unburden the user from javascript, etc. thanks in advance.
8
4173
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 controls like gridviews with selectable rows, buttons, textboxes. I'm using Ajax 1.0, and the users are still using IE 6. Some heavy users reported that the application starts to run slowly after a while, and task manager shows the memory usage...
7
2811
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 just ScriptManager object in it. Every time I refresh the page the memory usage goes up. I have AJAX extenstions 1.0 installed and IE7 on winxp. Is this IE or AJAX problem, and how did you guys cope with this problem? Please reply asap... i am...
22
9370
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 memory leak someplace. I can not detect the memory leak by running several reports by hand, but when I run tha app as a servrice and process few hundred reports there is significant memory leak. The application can consume over 1GB of memory where it...
0
9710
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9589
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10593
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9163
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3000
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.