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?