Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Freeing link list

Posted on 1998-07-06
1
Medium Priority
?
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 16

Accepted Solution

by:
imladris earned 300 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.
Suggested Courses

705 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