Stop Memory Leaks - Extension Tend To Crash When There Is No Internet Connection
Dec 4, 2010
The problem is, the extension tend to crash when there is no internet connection, and sometimes, the http requests fail to communicate with gmail server, they got built up over time and end up flooding the memory.
I have a javascript code with a countdown timer that runs on the client side and is updated regularly to the date set in mysql db.
I want to make the timer stop when the internet connection is lost. I am thinking on using clearTimeout()...but I need to associate it with the internet connection.
I have a script which needs to detect when the internet connection is lost and hold the content of the web page until the connection is restored.
I have been given a head start with a small javascript which I am trying to get to work.
My web page, I have a web page which contains some text and graphics but more importantly it also has an iFrame. The iFrame connects to an SQL database and displays data which is refreshed every 20 seconds.
Because the internet connection at the location where the script will be running I get connection loss which makes the iFrame loose its data. The Javascript I am working with is below.
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.
I have the AJAX-script. It eats memory about 4Kb per one callback. Script reflects messages from server application in real-time. I form messages, and put them into the iframe. If mesages more than 40 last message delete. Can you check the script and say about my mistakes? Code:
I have a question regarding how to prevent memory leaks in Internet Explorer when using closures. I already knew about the circular reference problem, and until now was able to prevent memory leak problems. But I needed to store DOM elements and can't solve it anymore. So I search the group archive to see if I missed any valuable information. I found some interesting articles, but somehow could not apply it to my problem or I did not understand it fully. In particular the articles that talked about setting variables to NULL seemed as an easy solution, but I think I didn't understand it, because it didn't seem to work.
So, let me explain my problem in more detail. I am working on some very dynamic and complex page. It uses AJAX (XMLHttpRequest) to alter different parts of the page. This already disqualifies the finalize method solution to cleanup memory leak problems. I use several "component classes" to do the work of creating DOM elements in some container element and provide an easy to use interface for manipulation the content. For example I can call component.setBackgroundColor("red") and the component takes care of changing the style on the correct DOM element that is encapsulated in the component. In reality the component uses more complex interface method, but I hope you get the picture of why I do this.
Let me show you some example code:
function MyComponent() { var div; var handler = null;
this.generate = function generate() { div = document.createElement("div"); div.onclick = MyComponent.createClickHandler(this); // normally more elements are created here return div; }
this.setBackgroundColor = function setBackgroundColor(value) { div.style.backgroundColor = value; }
this.getHandler = function getHandler() { return handler; }
this.setHandler = function setHandler(value) { handler = value; }
}
MyComponent.createClickHandler = function createClickHandler(component) { return function(event) { var handler = component.getHandler(); if (handler != null) handler(event); } }
This "component class" can be used like this:
var container = document.getElementById("container"); var component = new MyComponent(); container.appendChild(component.generate()); .... component.setBackgroundColor("red"); component.setHandler(function(event) {alert("Stop touching me!")});
The problem, of course, is that this code will create a memory leak in Internet Explorer. I need the component in the event handler to get the handler dynamically, but the div is stored there too, creating a circular reference.
One of the things I tried doing is making a DOMStorage "class" like this:
function DOMStorage() { var map = new Object();
this.get = function get(id) { return map[id]; }
this.put = function put(id, obj) { map[id] = obj; }
}
var storage = new DOMStorage(); //global
Instead of storing the div element directly in the component, I store it under an id in the DOMStorage and use it to retrieve it later. This actually prevented the memory leak. I don't really understand why, because I still see a circular reference. Maybe Internet Explorer does not count references in the global scope as a circular reference? When I move the global storage to inside the container object I get the memory leak again.
Unfortunately I am unable to use a global DOMStorage, because the "component class" in instantiated many times, and they must all have their seperate DOM elements.
Perhaps I have to generate unique ID's when I put a DOM element into the global storage? It seems so over-the-top for something that works perfectly fine in Firefox.
I'm working on an Ajax library that I plan to use on several upcoming projects. Everything seems to work just great...
Now I want to get into the finer aspects of checking things... How much memory am I using, are my objects making themselves available for garbage collection adequately, etc.
Are there tools you can recommend (especially for IE and Firefox) that I can use to get this information?
I have a table, 10 cols, 200 rows. Using tablesorter causes a memory leak on every page refresh of almost 2mB. A smaller table causes a proportionately smaller memory leak. Is there way to clear this memory? I've tried setting inner html of the table to '', but it makes no difference. Is there even a universal method i can call to remove any trace of any jquery plugin I have on the page?
I have a jquery based system with ajax calls instead of page refreshes. Every time I return some ajax content, it replaces the content on the main div.
function execcmdcallback(data, textStatus, XMLHttpRequest) { $("#divmain").html(data); data = null; }
Each time this executes, the browser memory increases by about 600-900kb. Can anyone suggest a way of doing this where the old memory is freed so there is no significant increase in browser memory on each ajax call ?
I've studied this a bit, [URL]..., but I have to admit I don't quite understand it I see the same issue on IE8, FF and Chrome. FF comsumes less memory per ajax call and frees some memory seconds later, but still the total working set is increasing on each call by 300k in FF and 600 to 900 in chrome and IE
I'm building a JavaScript-based calendar for a client that will require me to replace the page's HTML based on the user's input. For example, if the user clicks on a particular date, then the month/week calendar will be replaced with the day calendar. Needless to say, there are several event listeners involved. However, if I suddenly swap out the month calendar for a day calendar, does that mean that there are several event listeners in memory for elements that no longer exist? Or are those listeners destroyed when the elements are destroyed? Basically my question is, every time I swap out the HTML, do I have to detach all of the old events too?
I've been searching the web for a while now, and I haven't come across a conclusive solution for memory leaks due to replacing nodes with frequent AJAX updates. I wrote a class that pulls an RSS feed frequently (e.g. every 5 seconds) and updates an HTML element with new information. In the process, it removes the old nodes and replaces them with new ones. It works fine visually. The only problem is that it has terrible memory leak complications; when I put the script on to run, it increases the memory usage by about 1MB every few seconds at an accelerated 1000-ms delay between updates!
(That's 100MB every few minutes!) I discovered this when I let the script run for a few hours straight, not thinking anything of it, and when I returned to my computer, it was frozen up Opera seems to be the worst at its memory management on this script, Safari and Chrome are in the middle, and Firefox seems to handle it the best, but nonetheless there are memory leaks in all four. (I haven't tested IE yet, but based on what I read, I would expect that it might even be worse than Opera!)
I'm using window.open method in my script to open poup window. Recently Internet Explorer users reported that the script crashes on their machine with different runtime errors.
I'm having trouble finding example code to detect the presence of an Internet connection. It doesn't seem to be a very frequently asked question, as all I need is the answer yes or no (is the user connected or not).
I'm not interested in speed detection or any other aspect of the connection, just its existence or not. The reason is to be able to intercept link clicks on a CD-based set of HTML pages and pop up a warning if there is no connection; otherwise pass the request through to the net.
It is possible to run dynamic web pages on a pocket PC without internet connection?I would like to read/write files using a browser on my pocket PC without internet connection.
I am having an issue with a script which fails when the internet connection is lost, and so it should.
Is there a way that the web page can be automatically refreshed if the connection is lost using JavaScript. I need to continually refresh until the connection is back on.
I know all about META refresh but that does not help.
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:
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?
I am attempting to create an Access database connection from within an HTML page. I am using Javascript to make the connection and then test a basic UPDATE statement.
The following code is throwing back an error 'UPDATE statment syntax incorrect'
Code:
I thought the syntax was correct, but maybe it is something else?
<!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.
I am working in an application where either sometimes if I navigate to few pages or add few items, I am getting an "STOP SCRIPT" pop up in IE7 browser. I have been trying hard to resolve it but not finding any resolution which will help me clearing this issue for entire application in one go.
I am trying to get a dynamic table going. You click a button to add a row. In the newly created row a button to delete the row is placed (try the code example below). In Netscape, pressing the delete row button crashes the browser. Why ? What is the correct way to do this ?
I am stumped why this following code works in IE and Opera but crashes Netscape 7 (ie makes it disappear and try to send a bug report etc).
Any help would be much appreciated.
Copy and save the following code example and try running in Netscape 7 (or Mozilla 1.4) . It works fine in IE 6 and Opera 7. I've tried all sorts of tweaking around but to no avail.
I need some expert help. Perhaps suggest the correct or other better way of implementing this.
My site works fine in Firefox, but it crashes in IE.
I am using alot of jQuery in order to fade in content. When the user clicks on one of the above links a few times, it will crash in IE.
Here is my site code... I have absolutely no idea why the site crashes in IE. I don't even know where to begin to debug my problem. I don't have Visual Studio on my computer, but on my friends computer Visual Studio reads a message of An unhandled win32 exception occurred in iexplore.exe[####]
I'm writing some code so that my comments section automatically updates every 10 seconds. The code i wrote does update it but sends off about 40 request every 10 seconds until it eventually crashes the browser.