Yes I mean reachable from a root.

<snip>If it was able to determine whether objects were reachable without
performing a GC, it wouldn't need to do most of the work involved in
performing a GC!</snip>

Interesting.  I thought that the graph calculation was comparatively less
expensive than compacting the memory.

<snip>Why do you need to know this?</snip>

I cannot determine the lifetime of the objects I am caching (otherwise I
would make them disposable).  Many different objects may have picked up
references to them. The cache will periodically be passed an object that is
a different instance, but has the same logical identity as an object already
in the cache.  If the cached object is reachable from a root and it is
dirty, then the incoming object is discarded.  However, if the cached object
is not reachable from a root, then the incoming object should replace it.


-----Original Message-----
From: Griffiths, Ian [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 07, 2003 7:48 PM
To: [EMAIL PROTECTED]

What do you mean by 'rooted'?  Do you mean that it's reachable from a root?

If so, the problem is that the CLR never knows whether a particular object
is reachable except on the occasions when it performs a GC.  If it was able
to determine whether objects were reachable without performing a GC, it
wouldn't need to do most of the work involved in performing a GC!

Why do you need to know this?

--
Ian Griffiths
DevelopMentor

> -----Original Message-----
> From: Pinto, Ed [mailto:[EMAIL PROTECTED]
>
> I've got a cache that needs to know that a weakreference's target is
> rooted.
> What is the best way to do this?
>
> The cache is accessed ~20 times/second in a server environment, and
once
> per
> minute in a rich client environment.
>
> Calling GC.Collect would solve my logical problem, but I can't imagine
> that it would be very performant on the server.
>
> Are there other options I can use?  Would the profiler APIs help

Reply via email to