473,387 Members | 1,456 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,387 software developers and data experts.

Memory Leak with InnerHTML

I have spent the past few weeks trying to figure a way around this
problem, and have yet to find a good enough solution.

Internet Explorer leaks memory when I update a div container using
innerHTML, this does not occur in firefox. This would not be a problem
except the webpage is required to be left on for weeks on end without
being restarted. I presume the issue with innerHTML is that Internet
Explorer apparently parses what you give it and then decides on how to
construct the dom elements itself, so never truely creates what you
give it.

I know that the innerHTML is the problem as I have successfully
narrowed down the leak to that line. It only leaks memory when I assign
content to the innerHTML of my containing DIV. Appending a text node,
for example, with the exact same information to the same div does not
leak. Note I have also tried using such existing AJAX packages like
Prototype etc. but to no avail.

I need to do it this way as my XML documents are styled using an XSL
stylesheet and then transformed using transformNode [I will omit
details regarding firefox as there is no problem there]. I have looked
into transformNodeToObject as a way to get a dom object that I
originally assumed could be appended [as a child] to my containing
element. This did not work and gave me compatibility errors.

I suppose I am either looking for someone who has solved this problem,
or who has an acceptable work around. Or someone to say that it cannot
be solved.

I thank anyone in advance who attempts to help me. If you can help me
it would be GREATLY appreciated.

Below is a snippet of the final code I am using.

document.getElementById(container) = null;

output = http.responseXML.transformNode(xslProc);
if (output)
{
document.getElementById(container).innerHTML = output;
}
output = null;

Nov 20 '06 #1
2 4693
m0nkeymafia wrote:
Internet Explorer leaks memory when I update a div container using
innerHTML, this does not occur in firefox.
The vital piece of information that you left out in your post is the actual
html that you are inserting into the div.
The act of inserting html does not cause a memory leak by itself (that I
know of). The leak is most likely coming from the specific html that you are
inserting, or the way that you are using your ajax call (making a closure
without realizing it and leaking dom nodes).

Further, you're using xml/xsl which may cause other problems.

I suggest you take your leaking page and keep trimming away as much as
possible from it until you have a bare-bones test case that still leaks. At
that point, you can isolate the real problem - whether it's the html being
inserted, closures from ajax, xsl, etc. Once you have an extremely simple
test case that leaks, post it here if you haven't figured out the cause yet.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Nov 20 '06 #2
Thanks for the reply Matt, the code im inserting shouldn't cause
closures as it is pure HTML.
I didnt think that purely inserting HTML [with no reference to other
objects or any JS events] could cause a problem.

It is basically a couple of DIVs with some table elements inside, all
conform to strict xml standards.

Also what problems could arise from using xml/xsl transforms? I use one
XMLHttpObject rather than creating many in an attempt to stop memory
leaks, I also hold the XSL stylesheet in memory rather than
re-requesting it every time.

I will try cut down my style sheet so the XML it outputs is very basic,
it looks like I have been looking for problems in the javascript rather
than possible issues with my HTML output from the stylesheet.

Thanks again, I will be in touch.

Nov 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

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...
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: Peter Michaux | last post by:
Hi, Douglas Crockford mentioned in a video on Yahoo! that before removing an element it is a good idea to purge it's event handlers. I think he was only refering to the event handlers defined...
2
by: charlesjylee | last post by:
I am working with Netscape 7.0 and need to bind a <divwith the innerHTML property. More specifically, I need to bind a GridView in the div in question. I am binding the div with some hardcoded...
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...
10
rizwan6feb
by: rizwan6feb | last post by:
I am working on an ajax chat application, done most of the work but when i tested it on IE (both on IE6 and IE7), found that there is a memory leak. The application works fine on FF. How can i fix...
11
by: dhtml | last post by:
(originally mis-posted on m.p.s.jscript...) I've just closed all windows in Firefox and its using 244MB of memory. I have no idea why. I had GMail open, a page from unicode, the CLJ FAQ. ...
1
by: Daniel S | last post by:
Hi, I have an asp.net page with a GridEX inside an UpdatePanel. Every 20 seconds, I need to re-submit a query to the database and refresh the GridEX with the new results; however, each time...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...
0
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,...
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...

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.