Re: Memory leak on adding Form to a DOM node
- From: Thomas 'PointedEars' Lahn <PointedEars@xxxxxx>
- Date: Tue, 18 Sep 2007 21:40:22 +0200
Simon_21 wrote:
it is in addRowToTable()
cellLeft.innerHTML ="<FORM id="+ "form_"+rownum++ +
"<A>default.domain.invalid.default.domain.invalid</A></FORM>";
The moment I change the form to something else the leak stops, but I
don't have a clue why it leaks.
First, there is useless concatenation.
cellLeft.innerHTML = '<FORM id="form_' + (rownum++) +
'<A>default.domain.invalid.default.domain.invalid</A></FORM>';
Second, there is too much concatenation.
cellLeft.innerHTML = new Array(
"<FORM id='form_", rownum++,
"<A>default.domain.invalid.default.domain.invalid</A></FORM>"
).join("");
Third, this generates invalid markup, the <form> tag is incomplete.
Also, attribute values are not quoted (not a syntax error, but a
possible cause for the leak as the UA has to parse the markup).
cellLeft.innerHTML = new Array(
'<FORM id="form_', rownum++, '">',
"<A>default.domain.invalid.default.domain.invalid</A></FORM>"
).join("");
Fourth, the generating markup is not Valid itself: ETAGOs must be escaped
in HTML `script' element content or the element ends prematurely.
cellLeft.innerHTML = new Array(
'<form id="form_', rownum++, '">',
'<a>default.domain.invalid.default.domain.invalid<\/a><\/form>'
).join("");
Fifth, the generated markup is useless: the generated `a' element has
neither a `name', nor an `id' or a `href' attribute. What is the UA
supposed to do with that?
And don't forget to include
cellLeft = null;
after that.
But you have not posted the real code, so the above can only give you a hint
as to possible improvements of your code that might or might not solve the
problem. Also, from the sheer length of the wrapped code posted in
<1190092952.341003.177810@xxxxxxxxxxxxxxxxxxxxxxxxxxx>, it would not be
unreasonable to assume that MSHTML has its problems with that long a line.
That said, the proprietary `innerHTML' property should not be used anyway.
If you build the subtree with DOM Level 2 methods, you would stand much
less a chance to run into such apparent flaws of the DOM implementation.
HTH
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
.
- References:
- Memory leak on adding Form to a DOM node
- From: Simon_21
- Re: Memory leak on adding Form to a DOM node
- From: Simon_21
- Re: Memory leak on adding Form to a DOM node
- From: RobG
- Re: Memory leak on adding Form to a DOM node
- From: Simon_21
- Re: Memory leak on adding Form to a DOM node
- From: David Golightly
- Re: Memory leak on adding Form to a DOM node
- From: Simon_21
- Memory leak on adding Form to a DOM node
- Prev by Date: Character Encoding not identical between XMLHttpRequest and a form submit
- Next by Date: select does not display new child in IE7
- Previous by thread: Re: Memory leak on adding Form to a DOM node
- Next by thread: Re: Memory leak on adding Form to a DOM node
- Index(es):
Relevant Pages
|