Solved

Freeing link list

Posted on 1998-07-06
1
165 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

707 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

15 Experts available now in Live!

Get 1:1 Help Now