Domanda

I have a theoretical question.

short:

Will a transparent proxy object be collected if the last reference to it is a WeakReference, but the real object is still referenced in the host process.

example:

The used example does not make sense but the real scenario is too complex to describe.

Assumed there is a cache realized with WeakReferences as described here: WeakReferenceExampleMSDN

Now the cache is filled with objects which lives in another process (Remoting). These objects are in the local process only transparent proxy objects and their lifetime is controlled by the other process.

If there is no magic i assume the proxy object gets collected, because the proxy object is only a handle to the real object. After the first run of the GC the cache is empty.

  • Is there some magic and this theoretical cache will work with remote objects?
È stato utile?

Soluzione

The transparent proxy will be collected by GC. Therefore such a cache will not work for RemoteObjects

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top