Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Garbage collection after removing child nodes

Reply
Thread Tools

Garbage collection after removing child nodes

 
 
Tim Streater
Guest
Posts: n/a
 
      02-29-2008
I have a <select> that I build up dynamically. To later clear and
repopulate it, I can't use the standard trick of:

ptr_to_select.options.length = 0;

because sometimes the <select> will contain <optgroup>s. These stay in
the <select> (for Firefox and IE7, not Safari), after setting the length
to zero.

What seems to work on all browsers is:

while (ptr_to_select.childNodes.length>0)
{
ptr_to_select.removeChild (popup.lastChild);
}

but, are the removed children properly garbage collected? Especially as
some will be the <optgroup>s and have children themselves.
 
Reply With Quote
 
 
 
 
Bart Van der Donck
Guest
Posts: n/a
 
      03-01-2008
Tim Streater wrote:

> I have a <select> that I build up dynamically. To later clear and
> repopulate it, I can't use the standard trick of:
>
> ptr_to_select.options.length = 0;
>
> because sometimes the <select> will contain <optgroup>s. These stay in
> the <select> (for Firefox and IE7, not Safari), after setting the length
> to zero.
>
> What seems to work on all browsers is:
>
> while *(ptr_to_select.childNodes.length>0)
> * * *{
> * * *ptr_to_select.removeChild (popup.lastChild);
> * * *}
>
> but, are the removed children properly garbage collected? Especially as
> some will be the <optgroup>s and have children themselves.


The only way to know is to test with heavy data, and then see how many
CPU is freed by the browser after the delete-action is finished.

--
Bart
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      03-01-2008
Bart Van der Donck wrote:
>> [...] are the removed children properly garbage collected? Especially as
>> some will be the <optgroup>s and have children themselves.

>
> The only way to know is to test with heavy data, and then see how many
> CPU is freed by the browser after the delete-action is finished.


Memory (RAM), not CPU.


PointedEars
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen ASP .Net 1 05-18-2007 09:24 AM
select nodes with child node A and child node B gplott@yahoo.com XML 1 11-01-2006 09:27 PM
Selecting Nodes Using Subtotal of Child Nodes renfrochris@hotmail.com XML 1 08-24-2006 12:30 AM
Removing child nodes via XSLT or Xpath - newbie question jhoge123@yahoo.com XML 3 10-04-2005 03:03 PM
How do I: Main thread spawn child threads, which child processes...control those child processes? Jeff Rodriguez C Programming 23 12-09-2003 11:06 PM



Advertisments