I was just wondering what a ghost reference was? Is it that you don't have to refer to a object? EDIT: Sorry, I wasn't clear, the langauge is Java, and I read it about linked lists. While reading a problem to write a LinkedQueue iterator to support the remove method. Then, you would have a ghost reference.
What is a Ghost Reference?
7.4k views Asked by Roxy At
4
There are 4 answers
0
On
As I stated in the comment, I don't know of a ghost reference, but this article has a nice write-up on the various weak references (weak, soft, and phantom). It even mentions the ReferenceQueue
issue, though I must say that I hadn't heard that before.
0
On
GhostReference
the most recent concept that I know is PhantomReference
, if you want to know it, by my experience, you should understand Strong reference
then weak reference
then soft reference
. after these knowledge, you might more easily to understand PhantomReference
.
In short word, these reference just help garbarge collector works more properly. (It means some times, you don't need to know these concepts and you program still run ... in short time)
I'm not sure if this is the same, but I think you might mean a weak reference.
Weak references are used in languages that have garbage collection to have a reference to an object without blocking the garbage collection from deleting the object if no non-weak references exist.
Different languages have different semantics for this functionality. Java defines soft, weak and phantom references, each with slightly different mechanics.
This is useful in many situations. For example, on the Blackberry, you can define a Listener object that listens for system events (such as a call coming in). When you register your listener with the system, it keeps a weak reference to it. That way, when all other references to that object go away (such as when the application shuts down), the weak reference no longer points to the listener and the memory is for that listener is freed without the programmer having to remember to unregister it.