AllExperts > Java 
Search      
Java
Volunteer
Answers to thousands of questions
 Home · More Java Questions · Answer Library  · Encyclopedia ·
More Java Answers
Question Library

Ask a question about Java
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Brian Ngure
Expertise
Strong in Java. Will be able to answer both in areas of designing and coding. Some knowledge in servlets

Experience
5 years of Java experience, Sun Certified Java Associate and Sun Certified Java Programmer, JDK 1.4

 
   

You are here:  Experts > Computing/Technology > Focus on Java > Java > LinkedList

Java - LinkedList


Expert: Brian Ngure - 9/8/2009

Question
Brian,

Hopefully you can answer my question, as Google has failed me! :)

I'm using a LinkedList as a Queue in a 1.4 environment. It basically puts things in a static list that is then popped off by a active "listener" that I have running in another thread.

My program ended up running out of memory and threw a heap dump that I then analyzed and it showed that this "queue" was the culprit.

I then debugged it and noticed that in the Eclipse debugger it was showing the "size" of the linked list as 1, but there are references still to the other objects that use to exist on it - this says to me that even though I am popping these things off the list (I use the removeFirst() fuction by the way) they are still being retained in memory and GC isn't picking them up ever.

I added a function in that waits for about 4 minutes to go by then it reinitialized the queue and this seems to have solved my problem.

Question is, is this a downfall of the removeFirst() or could it be something else causing this? I kind of had to write some gimpy code that just copy's the queue into a new queue in order to remove the previous references.

I have attached a screen shot of what I'm talking about. Linked List size shows 1, but it still has 2 references at the top level (and shows more references father down the line)

Thanks!
Kris

Answer
Hi,

Sorry, but I have not been able to find any reason why this is happening. I have had a look at the removeFirst() method but does not give me any clues. Could you test with a newer JDK to see if it was a bug that might have been fixed?


Brian

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.