jcalfee314
jcalfee314

Reputation: 4830

java store objects that may be garbage collected

In Java, I recall there is a way to store objects in a usable format that may be garbage collected. It is some sort of loose reference. If they get garbage collected there is a way to detect and reload.

I'm having a hard time finding this. There is so much information about GC in general. Anyone know the name?

Upvotes: 2

Views: 100

Answers (3)

Rob Harrop
Rob Harrop

Reputation: 3473

I think you're looking for the *Reference classes in java.lang.ref. The ReferenceQueue class allows you to be notified when a reference is collected.

You might also find FinalizableReference from Google Guava useful.

Upvotes: 1

bdonlan
bdonlan

Reputation: 231163

You're thinking of Weak References.

Upvotes: 1

wolfcastle
wolfcastle

Reputation: 5930

I believe you are looking for WeakReference

Upvotes: 4

Related Questions