473,388 Members | 1,600 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,388 software developers and data experts.

Garbage collector / Rekursive Structure

Hi
i have a class (Item) and a typed collection
(ItemCollection:CollectionBase).
Each Item can have Sub-Items and each Item has a Reference to his
"Parent Item".

in brief:

public class Item
{
private ItemCollection subItems=new ItemCollection();
private Item parentItem = null;

public void AddSubItem(Item subItem)
{
subItem.ParentItem = this;
this.subItems.Add(subItem);
}
}
A "Structure starts" with a main-Item, adding SubItems, Sub-Sub-Items,
Sub-Sub-Sub-Items e.g. reading Data from Database or file).

public class Viewer
{
public void View()
{
Item mainItem = new Item();
// ... adding sub, sub-sub, ..... items
// do smth. with mainItem

}

}

Now my Question: can garbage collection remove mainItem, all sub-Items
and collections automaticly
should I do smth. special at the end ov Viewer.View() (beacuse of the
parent ref.), eg. setting alle "Parent-References" manually to null...

thank you
Peter.
Aug 2 '08 #1
1 976
Peter wrote:
i have a class (Item) and a typed collection
(ItemCollection:CollectionBase).
Each Item can have Sub-Items and each Item has a Reference to his
"Parent Item".
Now my Question: can garbage collection remove mainItem, all sub-Items
and collections automaticly
Yes.

If the entire data structure is no longer reachable all the objects
can be GC'ed.
should I do smth. special at the end ov Viewer.View() (beacuse of the
parent ref.), eg. setting alle "Parent-References" manually to null...
No.

Arne
Aug 2 '08 #2

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

Similar topics

18
by: Larry Herbinaux | last post by:
I'm having issues with garbage collection with my long-standing service process. If you could review and point me in the right direction it would be of great help. If there are any helpful...
13
by: Mingnan G. | last post by:
Hello everyone. I have written a garbage collector for standard C++ application. It has following main features. 1) Deterministic Finalization Providing deterministic finalization, the system...
2
by: lelandguo | last post by:
Hello everyone. I have written a garbage collector for standard C++ application. It has following main features. 1) Deterministic Finalization Providing deterministic finalization, the...
4
by: Carl Banks | last post by:
On Apr 12, 7:02 am, andreas.eis...@gmail.com wrote: Well, the garbage collector activates whenever allocations exceed deallocations by a certain amount, which for obvious reasons is the reason...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.