This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes When is the memory occupied by elements in javascript released Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "When is the memory occupied by elements in javascript released" Watch "When is the memory occupied by elements in javascript released" New topic
Author

When is the memory occupied by elements in javascript released

ravisha andar
Ranch Hand

Joined: Feb 25, 2011
Posts: 55
Hi All,

I java the garbage collector frees the memory occupied by the variables of type String etc...................

How does the memory occupied by elements get cleared in javascript other than when the browser is closed.

For example

var a = document.getElementById('div');
When is the memory occupied by variable 'a' released.


And if we do

removechild(a);

What happens to the memory occupied by 'a' ?

Please help me understand this

Thanks

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61457
    
  67

JavaScript employ garbage collection just like Java. So objects are eligible for garbage collection as soon as there are no more reference to them.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: When is the memory occupied by elements in javascript released