How to free memory in Javascript?
- From: "Ian Boyd" <ian.msnews010@xxxxxxxxxxxx>
- Date: Thu, 7 Aug 2008 09:43:37 -0400
How do i free memory in Javascript?
Example 1:
var i;
i = 1;
How do i free i?
Example 2:
var i;
i = 1;
i = 2;
How do i free the value 1 stored in i before i assign 2?
Example 3:
function DoStuff()
{
var i = 1;
}
How do i free i?
Example 4:
var button;
ExecuteButton = document.getElementById("buttonExecute");
How do i get rid of the reference to button?
Example 5:
var saleDate;
saleDate = new Date();
How do i free the Date object?
Example 6:
var saleDate;
saleDate = new Date();
saleDate = new Date();
How do i get rid of the first Date object?
Example 7:
var mycars = new Array();
mycars[0] = "Saab";
mycars[1] = "Volvo";
mycars[2] = "BMW";
How do i free the memory associated with the array?
Example 8:
var t = setTimeout("DoStuffTimer()", 1000);
How do i free the timer associated with t?
Example 9:
var t;
t = setTimeout("DoStuffTimer()", 1000);
t = setTimeout("DoStuffTimer()", 500);
How do i free the first timer?
i used to assume that javascript was a garbage collected, reference counted
language, and that as soon as a variable goes out of scope (and as such all
references to it are released) the memory is freed by the garbage collector.
But i cannot find anything to back up my feeling.
i've tried googling for such questions, but people are intent on talking
about memory leaks caused by circular references and closures. i'm not
interested in those, nor am i interested in memory that is freed when the
browser navigates away from a page.
i have a page that will be running for weeks straight, if not months or
years - i want to know that a local variable in a function is being freed
once it goes out of scope. i was to know that everything is an object, and
once that object has no references it too is freed.
And i cannot find anything to indicate that memory i'm using is ever freed.
.
- Follow-Ups:
- Re: How to free memory in Javascript?
- From: Anthony Jones
- Re: How to free memory in Javascript?
- From: Bob Barrows [MVP]
- Re: How to free memory in Javascript?
- From: Joe Fawcett
- Re: How to free memory in Javascript?
- Prev by Date: RE: How to dectet the word count/character count in an DIV or any oth
- Next by Date: Re: How to free memory in Javascript?
- Previous by thread: RE: How to dectet the word count/character count in an DIV or any oth
- Next by thread: Re: How to free memory in Javascript?
- Index(es):
Relevant Pages
|