473,327 Members | 2,118 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,327 software developers and data experts.

Javascript Leak setting style.backgroundImage

Hello,

Can someone please tell me why this code leaks? The handle count for IE
continues to increase.

var newimage = "url(images/" + res.value[i].Image + ")";
if( imagetd.style.backgroundImage != newimage )
{
imagetd.style.backgroundImage = "";
imagetd.style.backgroundImage = newimage;
}
I'm using a setInterval to call the function. If I comment out the
change of the background, i get no leak.

This doesn't leak:

var newimage = "url(images/" + res.value[i].Image + ")";
if( imagetd.style.backgroundImage != newimage )
{
//imagetd.style.backgroundImage = "";
//imagetd.style.backgroundImage = newimage;
}

Any help would be greatly appreciated.

Thanks

Feb 16 '06 #1
3 11301
VK

fehays wrote:
Hello,

Can someone please tell me why this code leaks? The handle count for IE
continues to increase.

var newimage = "url(images/" + res.value[i].Image + ")";


What are res, value[i] and Image? Are these your custom JavaScript
objects or some are form elements?

Feb 16 '06 #2
Those are custom objects created by the ajax .net dll i'm using.

Feb 16 '06 #3
VK

fehays wrote:
Those are custom objects created by the ajax .net dll i'm using.


Actually all these "script memory leaks" is a new "blame on it" subject
recently :-)
As JavaScript / JScript has an automatic garbage collector schema (like
in Java), there are very few situations where you really can say
"memory leak". Amount of used handles or used memory increase by itself
*doesn't mean anything*. You script may calculate var a = 2+2 and have
99% of allowed memory used. And a minute later it may start calculating
the purpose of this universe and the memory usage will be 1%. It's not
a C-like construct/destruct here ;-)

If some time later you're getting "Out of memory", "Stack overflow" or
your system gets unresponsive, then let's look for a leak.
If nothing of this, then don't bother with system monitoring - it works
in its way and most probably it works just fine.

If your particular situation is bothering you, try to call undocumented
CollectGarbage() method and see (whatever system monitor are you using)
if the number of used handles will drop at least a bit.

If not, let's see where and how are you getting the imagetd reference.

Feb 16 '06 #4

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

Similar topics

4
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
1
by: C A Upsdell | last post by:
I have a site where I am setting a style dynamically, using the JS statement: obj.style.backgroundImage = 'url(img/bak_page.jpg)'; where 'obj' is either document.getElementById(id), or...
2
by: Norman Swartz | last post by:
OS system is Windows XP Pro SP2. The following works perfectly in IE but not at all in Netscape: <tr> <td valign="middle" background="dull.gif" onMouseOver="this.background='bright.gif';"...
2
by: Cy | last post by:
Hi, I have a menu that toggles correctly in IE but is failing in FireFox V.1 and Netscape 7.1. The FireFox JavaScript Console is returning the following error; Error:...
3
by: jimmygoogle | last post by:
I posted earlier with a scope problem. I think I resolved it in IE but in Firefox it still exists. Anyone have any ideas/experience with this? I attached my code sorry it is so long. You can...
3
by: Jim Land | last post by:
Jack Slocum claims here http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript- memory-leaks/ that "almost every site you visit that uses JavaScript is leaking memory". ...
60
by: marss | last post by:
Maybe anyone know good free online JavaScript knowledge test? This not exactly a system for testing online required - it may be simply list of questions with variants of answers (I have to prepare...
5
by: woody79 | last post by:
The element to be changed: <div id="bar"><div class="left">&nbsp;</div><div class="right">&nbsp;</div><div class="barbot">&nbsp;</div></div> This what changes it, but does not do anything:...
2
bilibytes
by: bilibytes | last post by:
hi, i am getting an error with this script: "oCk is not defined onclick(click clientX=0, clientY=0)" //widget functions //1. //when the mouse is over a star, we want to change all...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.