Solved

Freeing link list

Posted on 1998-07-06
1
170 Views
Last Modified: 2010-04-16
I have a program which contains a complicate link-list.  If I free the header of the link-list, does Java garbage collection free the whole link-list for me or do I need to remove the reference for each link in the list?  Right now, I have a lot of memory problem with this program.  Without destructor method like in C++, I don't know how to free all of instances of objects created by "new" methods.
0
Comment
Question by:QianYang
1 Comment
 
LVL 16

Accepted Solution

by:
imladris earned 100 total points
ID: 1224882
Yes, Java garbage collection takes care of freeing the memory. One fly in the ointment could be that there are other references to elements in the list, elsewhere in the program. As long as anything is referenced, by any "live" (in scope) variable, the garbage collector will not be able to free those objects. If there are such variables, the solution is to assign them "null" so as to remove the reference.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now