473,473 Members | 1,807 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Garbage collection after removing child nodes

I have a <selectthat 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 <selectwill 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.
Feb 29 '08 #1
2 1803
Tim Streater wrote:
I have a <selectthat 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 <selectwill 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
Mar 1 '08 #2
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
Mar 1 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: James S | last post by:
Hi, Basically I've been fighting with this code for a few days now and can't seem to work around this problem. Included is the output, the program I use to get this error and the source code for...
5
by: Mateo | last post by:
Let's say that I have panel control which is container control, and I need to access every child control inside panel control from JScript. I have this line of JS code: var oCollection =...
2
by: Greg | last post by:
Hi. I have a rather large xml document (object) that can have one or more nodes with a certain attribute throughout (at ANY depth, not at the same level necessarily). I need to find this...
1
by: Chris Bardon | last post by:
I'm working on a class library in .net, and am having a problem that I can only describe as a memory leak (which garbage collection was supposed to eliminate). My class library contains a single...
6
by: Jan Krouwer | last post by:
I have a treeview which is populated from a relational database. In order to copy part of the tree, I need to add to the database the relationship of the part of the tree to be copied but with new...
142
by: jacob navia | last post by:
Abstract -------- Garbage collection is a method of managing memory by using a "collector" library. Periodically, or triggered by an allocation request, the collector looks for unused memory...
7
by: Peter Michaux | last post by:
Hi, Below is an example from Flanagan's fifth edition Ajax chapter. It looks to me like the "request" variable might be eligible for garbage collection after this function executes. This would...
1
by: dd | last post by:
I have a situation where the browser memory goes up and up as each Ajax call causes new content to be deployed into a DIV. I'd like to know if I can force garbage collection to occur. More...
2
by: Jordan S. | last post by:
Using .NET 3.5... I have the following class: class NodeDescriptor { // Properties only in this class public int NodeID { get; private set; } public int ParentNodeID { get; private set; }...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.