JS Memory Leak Prevention?
Jan 19, 2010
Do the latest browsers still need this? I could find an article about IE8 which states that its garbage collection has improved so circular references shouldn't be a big problem any more.Reason for asking is that I maintain an JavaScript / AJAX framework and we are currently optimizing our code which contains a lot of code to remove references from and to the DOM and to remove event listeners.
View 1 Replies
ADVERTISEMENT
Mar 26, 2009
First the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title></title>
<script type="text/javascript">
function TextScroll(scrollname, div_name, up_name, down_name, top_name){
[Code]...
When I use mouse wheel in Firefox to scroll contents of the DIV, memory usage in Firefox goes through the roof. Code above is a fully working page, if anyone would like to see what's up, just load it up, and start moving your mouse wheel in the area with text. You don't actually have to scroll the text, just moving the wheel back and forth in that DIV will do. Memory usage will start going up quite fast, and after you stop moving the wheel, it will finally come down a bit after a short while. I've highlighted in red the line where mousewheel event is registered for Firefox. I'm not sure if it's really a problem, but since Opera and IE don't have any strange memory usage, and Firefox does, maybe I did something wrong. In everyday use it shouldn't matter [don't expect to have kilometers of content to scroll], but anyway, it is a bit unsettling.
View 2 Replies
View Related
May 2, 2006
I've been putting together a small pet project. Once it was finished i realised it had a gigantic memory leak inside of it. I tried to read up on the subject, but couldn't find the source of the problem via the articals.
This site is very simple, so I'd think idenifying (and hopefully fixing) the problem would be easy. Here is the relavent portions of JS (followed by links to the full page incase you need to see that): Code:
View 6 Replies
View Related
Mar 26, 2006
I was wondering how good is JavaScript with memory management. I have
an object called MANAGER that has a list of other objects, each one
managing a single DOM nodes, etc. In my implementation of
MANAGER.reset(), I simply recreate my MANAGER.object_list = new
object(); and do a single MANAGER.domnode.innerHTML = '' as apposed to
getting my hands dirty. Is my app leaking memory?
View 4 Replies
View Related
Nov 20, 2006
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.
View 2 Replies
View Related
Feb 19, 2010
Below is my code which refreshes every 10 seconds
[Code]...
What happens there is a memory leak of the divs with idsliveAuthen-target-1000 andliveAuthen-content-1000
View 6 Replies
View Related
Oct 3, 2007
I posted this originally in the csharp group, but I think that may be the wrong group. This seems more appropriate:
I'm running into an issue with a memory leak in an Asp.Net web page.
In the code behind (.cs) I'm adding onchange, onblur and onfocus events to a bunch of objects that reside on my page (textboxes and dropdownlist).
After using Drip i've found that these are leaving open DOM objects....
View 9 Replies
View Related
Mar 12, 2010
I have started using jQuery recently and I am having a problem with IE leaking memory when performing a $.getJSON() request at intervals. To test the problem I set up the code to run every second. The only code I currently have running is the ajax request as below:
getDetail = function(detailID){
$.ajaxSetup({ cache: false });
$.getJSON("api/urlgoeshere", {"dID" : detailID,"d" : 0},
[Code].....
If I leave the above running the Memory Usage climbs by about 5mb a minute in IE but is ok in Firefox. I am using jquery-1.4.2. Has anyone come across this before?
View 1 Replies
View Related
May 28, 2011
Attached is a sample html file (named jqmleak.html - rename it to remove the txt extension and drop it into your web server to test for yourself) that I've put together to demonstrate a memory leak with the $.ajax function in jQuery 1.6.1 when run in Firefox 4.0.1. The file loads jQuery 1.6.1 from the Google API CDN. Next, a simple function is defined that runs $.ajax to request the html file itself. This function is then set to run once every second using setInterval.
In Firefox 4.0.1, on both Win XP and Linux (ubuntu 10.10, 64-bit), I can watch the amount of memory consumed by Firefox gradually rise. It takes a few minutes for the problem to be observed, because initially the memory will decrease with no other activity in the browser. Then after about 5 minutes or so, I can watch the memory used by Firefox slowly but steadily increase. I can use the handy 'about:memory' tool in Chrome to monitor this alongside other browsers. Chrome, Opera, and IE do not exhibit the same problem with this test. Their memory usage will vary within a range of about 2 or 3 mb, but over a long period of time they do not increase their total amount of memory used. This problem is only happening in Firefox 4.0.1 as far as I can tell (I also used safe mode in Firefox to make sure no plugins were interfering with the test). I have tried both GET and POST methods with the $.ajax call, and with the cache setting both enabled and disabled. The result is the same.
Is this a jQuery problem, or maybe instead a bug with Firefox? I see similar bugs reporting memory leaks in other situations, but usually specific to IE. I was about to report a bug for this, but I thought I'd check here first to see if anyone can duplicate this problem, and/or point out what I should do to prevent the memory leak in Firefox.
View 2 Replies
View Related
Mar 13, 2007
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 data (a
table, which is the HTML equivalent of a GridView). Is there a way
with javascript to dump the memory used by a DOM object (the div that
I am binding with innerHTML)? When i just receive the variable in
javascript, it doesnt seem to leak. I have tried removing and adding
the div each time I bind to it, but it still leaks.
Here is the code:
View 2 Replies
View Related
Sep 12, 2009
I have a page that dynamically loads and unloads whole sections and creates complex links between various objects and have never been sure exactly what happens when an object that is being observed is deleted from the DOM. Since there is no longer any link to deleted objects, the listener objects obviously won't receive any updates, but do the underlying "listener" connections get purged as well? I guess it would depend on whether the listening mechanism is part of the listened-to object or is maintained in a separate area of the browser.
View 1 Replies
View Related
Jul 27, 2002
I found this on JavaScriptKit. It checks to see if the site accessing the data is your domain. I found it pretty cool.
//Beginning of "test.js" file
var accepted_domains=new Array("wsabstract.com","javascriptkit.com")
var domaincheck=document.location.href //retrieve the current URL of user browser
var accepted_ok=false //set acess to false by default
if (domaincheck.indexOf("http")!=-1){ //if this is a http request
for (r=0;r<accepted_domains.length;r++){
if (domaincheck.indexOf(accepted_domains[r])!=-1){ //if a match is found
accepted_ok=true //set access to true, and break out of loop
break
}
}
}
else
accepted_ok=true
if (!accepted_ok){
alert("You're not allowed to directly link to this .js file on our server!")
history.back(-1)
}
/////rest of your libray
"
"
"
View 1 Replies
View Related
Feb 22, 2001
i want the browser to test wether or not a page that is
called is beieng called from within the specified window
the script is originally used to prevent a page within a frame to be called alone it redirected the user to the main window if i can call it that so that parts of
your frames could not be viewed alone
i have managed to secure most of my site
no rightclicks can be performed and no options to view
source code by using a chromeless window the problem now
is that i wanna make sure that someone cannot call a page
into a normal browser window by using shift while clicking
on links thus preventing anyone from getting to my source code.
View 10 Replies
View Related
Dec 11, 2006
I'm using Drip 0.5 to test for a memory leak in some code. After reducing
the page down bit by bit to find the leak, I ended up with an empty page
that still leaked!
The page source is exactly this:
<html>
<head><title></title></head>
<body></body>
</html>
It doesn't leak the same amount each page load - sometimes it's 8192,
sometimes it's 16384, sometimes even reducing the memory load. But the
overall trend is an upward movement. I let it run for 10 minutes and it
leaked almost 10MB, so it's about 1MB/min.
This is not a serious leak, but it's making it harder to know if a leak is
caused by the js code or this other thing going on.
Has anyone else run into this? Any ideas what the problem is? I've shut down
all processes, removed all IE add-ons, etc, but no change.
View 1 Replies
View Related
Jan 27, 2007
I need help with this code. its a counter.
var count= 0
function onm() {
atextbox.value=ffee
count++
setTimeout(onm(),100)
}
And in the body:
<body onload="onm()">
<input type="text" value="0" name="atextbox">
</body>
I get always an error: Out of memory
View 3 Replies
View Related
Mar 16, 2009
I am using javascript to load and parse a big xml file (around 1 mb) save some values to an array and draw a picture using google Flot. Unfortunately, this causes the browser to crash! Is there a way to clear the memory of the browser?
View 2 Replies
View Related
May 27, 2010
I am developing a simple image editor in an HTA (for a special use-case). Because it is an HTA, it runs in IE only (IE7 to be precise).
Everything is working great so far, however, because I am loading the same img src file over after every edit, I had to attach " + Math.random();" to the image src so that the updated image is displayed.
This has lead to some pretty severe memory issues, as each time I make an edit, it caches another image. Under normal operation, my app uses under 20MB with a single image loaded, however after every edit it adds about 3MB. After a few minutes of testing I have had it consuming over 200MB!
Is there another way to use the same file name, same image src, etc, but have the browser re-read the file before displaying it again rather than using a cached copy.
Alternately, is there a way to make the browser forget about the other copies it has in memory to keep memory usage under control.
View 2 Replies
View Related
May 22, 2010
I'm trying to make a calculator in HTML/Javascript but I'm having trouble with the memory buttons. Here is the code:
<html>
<head>
<title>Env X Software | Env X Online Calc</title>
[code]....
View 9 Replies
View Related
Jul 4, 2009
I'm writing a very complex javascript application and I'd like memory usage to be as low as possible, so I've got a question about objects.
I'm using jQuery and my code is a bunch of jQuery plugins that interact with eachother. Will there be a difference in memory usage if I declare functions like this:
I haven't written anything in javascript as complex as I'm about to write, so I never worked with objects. As far as I understand, $.fn.whatever will add function to prototype, while $.whatever will add function only to one entry of jQuery object.
So question comes down to this: when jQuery object is being created, are functions in it being copied (meaning increase in memory usage) or does javascript only make references (meaning no significant increase in memory usage) to one main entry of that function in prototype?
View 3 Replies
View Related
May 18, 2010
what is DOM maximum memory size? is Diff from browser to Browser?
View 1 Replies
View Related
Oct 5, 2011
take a look at the below code. The below code is small representation of a bigger system.
HTML Code:
<html>
<head>
<style type="text/css">
</style>
[Code]...
However the problem is that once the tabs/iframes are removed the browser does not release the memory. This happens both in IE8 and FireFox. So over a period of time the memory consumed by the browsers are huge because of the creation and deletion of new tabs/iframes and the application slows down. Is there a way to make the browser release memory when an iframe is removed.
View 2 Replies
View Related
Apr 26, 2011
What is the best way to prevent memory leaks in IE6 and IE7?
I'm working on an internal web app that just gets slower and slower, using more and more CPU load and memory, unless and until you close the browser and start, again.
View 1 Replies
View Related
Jul 23, 2005
I am a little confused how the memory for objects is allocated in
JavaScript. David Flanagan, in "javascript: The Definitive Guide,"
states that each property of a class takes up memory space when
instantiated. So space is created for aMethod three times in this
example: Code:
View 9 Replies
View Related
Aug 19, 2006
I want to get the physical memory status, say, the total amount of
physical memory, the free memory, and so on, from the javascript, is it
a mission impossible?
View 2 Replies
View Related
Mar 16, 2011
It is possible to remove a function from the memory? I have a custom function that I call usingmodul.StepGuide.init() - but how do I remove that function with all its vars and events, from the memory.
View 1 Replies
View Related
Feb 5, 2009
is there a "javascript" way to enable cookie memory to whatever a user does. for example, if the user wants to edit something and then save it and the cookie will memorize it even if they clear cookies??
View 1 Replies
View Related