Re: Static Dictionary<s tring,object> ; vs Cache
It depends on what you need ;-p
Most importantly, most cache implementations will provide thread
safety, which a static dictionary (by itself) doesn't - you'd need to
do your own synchronization . But cache implementations may also offer
options for lifetime, dependencies (file system, etc), serialization,
etc.
Re: Static Dictionary<s tring,object> ; vs Cache
Where you use this,
[web/forms/service]
My understanding is that it *used* to make a lot more difference,
since without "web" it didn't fire up a thread to recover the memory -
but I thought that was now fixed, allowing you to use the cache from
System.Web in any scenario? Correct me if I am wrong...
And of course that is just the System.Web cache; most implementations
are architecture neutral / agnostic.
Re: Static Dictionary<s tring,object> ; vs Cache
On May 18, 5:41 pm, Marc Gravell <marc.grav...@g mail.comwrote:
Where you use this,
[web/forms/service]
>
My understanding is that it *used* to make a lot more difference,
since without "web" it didn't fire up a thread to recover the memory -
but I thought that was now fixed, allowing you to use the cache from
System.Web in any scenario? Correct me if I am wrong...
>
And of course that is just the System.Web cache; most implementations
are architecture neutral / agnostic.
>
Marc
Hi thank you for that.
I am using a Web application. The reason why I am asking this
question is the memory usage, as currently we are getting out of
memory errors, though these dictionary objects only take 27 meg of
memory, would putting these into Cache would be better from a memory
point of view?
Re: Static Dictionary<s tring,object> ; vs Cache
Well, the cache is likely to have more sophisticated scavenging
rules... but this isn't a great help if your code detects the missing
cache data and simply re-fetches it.
If you are getting memory errors, I'd first want to understand where
all the memory has gone, with profiling tools (the inbuilt performance
counters are the first thing to look at - what is the memory graph
like? a diagonal line is never good...)
Hi thank you for that.
>
I am using a Web application. The reason why I am asking this
question is the memory usage, as currently we are getting out of
memory errors, though these dictionary objects only take 27 meg of
memory, would putting these into Cache would be better from a memory
point of view?
27 MB of memory *per* dictionary, or 27MB of memory *for all* dicionaries?
If it's per dictionary, then it wouldn't take too much to overload a server with
even 4GB+ of RAM (assuming a single sesssion consumes only the 27MB in the
cache, it's roughly 148 sessions to eat 4GB).
That's a lot of memory to consume either way. What are you storing in it?
Comment