How to free memory in Javascript?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.


.



Relevant Pages

  • Re: How to free memory in Javascript?
    ... saleDate = new Date; ... 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. ...
    (microsoft.public.scripting.jscript)
  • Help me fix a small unit?
    ... I've tried a few memory leak detectors, and two of them show some promise. ... MemBlockCount: LongInt = 0; ... cmp eax,edx ...
    (alt.comp.lang.borland-delphi)
  • Re: Creating my on variable
    ... var = new Roby(); ... simply reinitializes the memory of var, it doesn't perform a new allocation. ... And declared two structes as that struct. ...
    (microsoft.public.dotnet.framework)
  • Re: Pointer to record
    ... You are trying to create a persistent block of memory which stores ... // memory used by PNewRec pointers ... so it may not compile or there may be some syntax errors etc. ...
    (borland.public.delphi.language.objectpascal)
  • Re: [PHP] Storing values in arrays
    ... PHP has not application var, and not multi thread ... the only way is database, share memory. ...
    (php.general)