473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Does an orhpan branch in the DOM get garbage collected?


I'm no sure of this,

If a branch is dynamically created and appended to an element and then
orphaned by removing and replacing it, are all the elements of that
branch cleaned up, or do they leek?

--
Ian Collins.
Mar 29 '06 #1
2 1133


Ian Collins wrote:
If a branch is dynamically created and appended to an element and then
orphaned by removing and replacing it, are all the elements of that
branch cleaned up, or do they leek?


If you do not keep a reference to the replaced/removed node then it is
free for garbage collection. But you do not know when the garbage
collection is run, it might only be run when the document with the
script is being unloaded.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 29 '06 #2
Martin Honnen wrote:


Ian Collins wrote:
If a branch is dynamically created and appended to an element and then
orphaned by removing and replacing it, are all the elements of that
branch cleaned up, or do they leek?

If you do not keep a reference to the replaced/removed node then it is
free for garbage collection. But you do not know when the garbage
collection is run, it might only be run when the document with the
script is being unloaded.

So is there a way to avoid memory leaks on a persistent page with
dynamically changing content?

--
Ian Collins.
Mar 29 '06 #3

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

Similar topics

4
by: Scott Robinson | last post by:
I have been having trouble with the garbage collector and sockets. Unfortunately, google keeps telling me that the problem is the garbage collector ignoring dead (closed?) sockets instead of...
4
by: Lester | last post by:
I have a low level question . . . If I have an assembly with a single class with a static int property, I know the assembly will get loaded the first time the class is referenced. At that...
3
by: Bryan | last post by:
I've been messing around with a C++ application on Xbox, and have been encountering problems with my objects getting garbage collected when they go out of scope, but before I'm actually done using...
4
by: Chris | last post by:
Hi, I think I'm having some problems here with garbage collection. Currently, I have the following code: public struct Event { public int timestamp;
3
by: Adam Smith | last post by:
Hi. I have a static arraylist in a class which is populated during the class's static constructor. Will this arraylist or the class objects allocated on it ever be garbage collected if I don't...
2
by: C P | last post by:
I'm coming from Delphi where I have to explicitly create and destroy instances of objects. I've been working through a C#/ASP.NET book, and many of the examples repeat the same SqlConnection,...
36
by: André | last post by:
Hello, I have a c# application that creates a timer to fire every minute using multithreading. On every minute it calls a Ping class that I made using sockets. It creates a new ping class then...
5
by: Ben | last post by:
Could someone please verify if what I am doing as follow is corrected: 1. when dealing with custom class objects: ..... public myObject as myClass myObject as New myClass .......here I am...
71
by: active | last post by:
In the main program I check to see if a certain form has been disposed. Does it make sense in that form's FormClosed event to do: Me.Dispose to make sure it is disposed the next time I check. Or...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
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
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,...
0
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...

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.