to use or not to use weakreference ?

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!
 
M

Mattias Sjögren

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
 
H

hb

Yes. I know what you mean.

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

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