I'm sorry, but I'm a bit confused by this. Ben just got done saying that he needs a mechanism whereby objects that were accessed least-recently are removed first, then you tell him that the garbage collector behaves more-or-less the opposite of what he needs, but that he should go ahead and use weak references, which gives him the GC behavior you just described. How is that a solution?
Maybe I'm misunderstanding the documentation, but it seems to be saying that if I have a weak reference to an object, the GC doesn't see that object as any different from an object to which I have no reference, even though I might want it to leave weak-referenced objects alone unless memory pressure requires them to be collected. It seems like a rather haphazard approach to caching, to me. System.Web.Caching.Cache uses quite a bit of P/Invoke interop to find out how much memory is free, and how much is being used by the cache, and such. I would think that if weak references were sufficient, they would be used by this object, but that does not seem to be the case. > -----Original Message----- > From: Moderated discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED]] On Behalf Of > John St. Clair > Sent: Tuesday, June 04, 2002 7:01 AM > To: [EMAIL PROTECTED] > Subject: Re: [ADVANCED-DOTNET] Size of object > > > > Anyone know if the Garbage Collector is spart enough to act > > on objects that > > were not used for the longest period of time ? > > Actually, the generational design of the garbage collection > ensures that if your objects are still referenced after a > long period of time, they will be the most infrequently > collected. Therefore, the "longest period of time" == least > likely to be garbage collected. I would, however, agree with > Ed (?), and suggest that you re-examine your design to use > weak references. > > John > > You can read messages from the Advanced DOTNET archive, > unsubscribe from Advanced DOTNET, or subscribe to other > DevelopMentor lists at http://discuss.develop.com. > > You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.