to use or not to use weakreference ?

  • Thread starter Thread starter hb
  • Start date Start date
H

hb

Hi

Suppose i keep my data query results in the cache using the cache object
that comes with .net. What do you think if i keep them in cache using
WeakReference so GC can collect them ?

I was doing some testes with it, but the items seem to be too much times
garbage collected... and my cache is "expiring" too much.... at the same
time, in a load test i've concluded that CPU is much more required when
using weakreference...

Can you give me your opinion ?
thanks!
 
Suppose i keep my data query results in the cache using the cache object
that comes with .net. What do you think if i keep them in cache using
WeakReference so GC can collect them ?

Only keeping a weak reference to the object, and thereby allowing it
to be garbage collected, seems to defeat the purpose of caching it.



Mattias
 
Yes. I know what you mean.

But suppose i only want to cache IF i have enough memory resources...
What do you think ?
 
Back
Top