observing a reference variable's instance

P

Pieter Breed

Hi,

I would like to have a reference to class instance, but not influence
when it should or should not be garbage collected. Is this possible?

I have a cache of objects that I use to send update signals with. The
cache manager should allow these instances to go out of scope and be
garbage collected, in other code. Normally the cache's reference to
the instance will prevent that instance from being collected. Is there
a way around this?

Regards,
Pieter
 
M

Mattias Sjögren

Pieter,
I would like to have a reference to class instance, but not influence
when it should or should not be garbage collected. Is this possible?

Use the WeakReference class.


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top