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

JavaScript Memory Leakage Problem With SetAttribute

Hello All,

I have made an AJAX call and bringing back some data from the server and then That data would be converted to XML through javascript. Now i am creating various elements like TABLE, TR, TD, Anchor to render that data using createElement method. and also i have to set some Usual and custom attributes to those elements and then render it on page.
Now my problem is when i use element.setAttribute(name, value) in a loop then after rendering 80 rows my IE shows alert that "This script is taking to long to run and should be aborted YES|NO " this kind of warning so can anybody help me where i am wrong and what kind of optimization can be done or there is any alternative for that.

This function is used for setting the attributes.

Expand|Select|Wrap|Line Numbers
  1.     function processTagAttributes(target, attributes){
  2.             if(attributes != null){
  3.                 for (i = 0; i<attributes.length; i++){
  4.                     var splited = attributes[i].split("|");
  5.                     if( splited[0] == 'style'){
  6.                             target.style.cssText =  splited[1];
  7.                     }
  8.                     else if( splited[0] == 'class'){
  9.                         target.className =  splited[1];
  10.                     }
  11.                     else{
  12.                         target.setAttribute( splited[0],  splited[1], 0);
  13.                     }
  14.                 }
  15.                 attributes = null;
  16.             }
  17.     }
EG attributes:--> var attributes = new Array("height|100", "width|100", "align|center");
Oct 31 '07 #1
5 2010
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

Why are you using three arguments for setAttribute? See link.
Oct 31 '07 #2
The third attribute is optional for overriding the case sensitivity of the attribute name


Defination provided by W3C Level 1

setAttribute Method

--------------------------------------------------------------------------------

Sets the value of the specified attribute.

Syntax

object.setAttribute(sName, vValue [, iFlags])
Parameters

sName Required. String that specifies the name of the attribute.
vValue Required. Variant that specifies the string, number, or Boolean to assign to the attribute.
iFlags Optional. Integer that specifies one the following flags: 0 When the attribute is set, it overwrites any attributes with the same name, regardless of their case.
1 Default. The case of the attribute that you set is respected when it is set on the object.
Oct 31 '07 #3
acoder
16,027 Expert Mod 8TB
That is not part of the standard. See W3C DOM Level 2 setAttribute(). Where are you quoting from?
Oct 31 '07 #4
First of all i must tell u that my development module is browser IE specific and the second thing is that i have written Level One See the link
http://msdn2.microsoft.com/en-us/library/ms536739.aspx
Oct 31 '07 #5
acoder
16,027 Expert Mod 8TB
First of all i must tell u that my development module is browser IE specific and the second thing is that i have written Level One See the link
http://msdn2.microsoft.com/en-us/library/ms536739.aspx
It's not part of level 1 either, but since your user environment is restricted to IE, it's not too much of a problem. Just be mindful not to use it on public projects.

Coming to your problem, how long does it take to render 80 rows? How many attributes are there and show the code you're using to call this function for the table rows/cells.
Oct 31 '07 #6

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

Similar topics

1
by: relaxedrob | last post by:
Howdy All! I am really stuck with this one - I want to completely create a table within JavaScript and insert it into the document, with onMouseOut and onMouseOver handlers in the table rows. ...
4
by: rick | last post by:
The following basic script works fine in firefox by not in IE. Can anyone spot the problem? In IE I can only delete the first line but not the lines created by javascript. Also, look at the HTML...
10
by: s.subbarayan | last post by:
Dear all, I happen to come across this exciting inspiring article regarding memory leaks in this website: http://www.embedded.com/story/OEG20020222S0026 In this article the author mentions:...
18
by: Ramasubbu Ramasubramanian XR (AS/EAB) | last post by:
What is memory leakage, could any one explain with sample code
4
by: Adam Smith | last post by:
Hello, How can I call or trigger an external javascript twice in a form? I have <script language="JavaScript" src="country_state.js" name="Country_State"> <script type="text/javascript"...
8
by: =?Utf-8?B?QW1yaXQgS29obGk=?= | last post by:
Okay, after much research, I have discovered a few interesting things in ASP.NET. I have a MasterPage that has a WebForm on it and it looks like this: <body> <form id="controls"...
14
by: madhawi | last post by:
i want to know that on what situation memory leakage happan and what is the solution to solve the problem of memory leakage.
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
11
by: prpradip | last post by:
I have an ImageList (_imageList). In _imageList I have put large numbers of Icons. Now what I need is to get Handle of all Icons that I put in _imageList, so that I can destroy (DestoryIcon) them...
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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,...

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.