473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Static Dictionary<string,object> vs Cache

I am using a static dictionary to objects (like cache) but woundered
if it is better to use cache.

Which one would should I use?
Jun 27 '08 #1
6 7221
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.

Marc
Jun 27 '08 #2
Where you use this,

It makes a big difference by instance if it is in
A web application
A forms application
A service application

And that is then the start.

Cor

<Pa*************@gmail.comschreef in bericht
news:c7**********************************@1g2000pr g.googlegroups.com...
>I am using a static dictionary to objects (like cache) but woundered
if it is better to use cache.

Which one would should I use?
Jun 27 '08 #3
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
Jun 27 '08 #4
On May 18, 5:41*pm, Marc Gravell <marc.grav...@gmail.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?

Jun 27 '08 #5
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...)
Jun 27 '08 #6
Pa*************@gmail.com wrote:
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?

Chris.
Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: Zombie | last post by:
Hi, what is the correct way of converting contents of a <string> to lowercase? There are no methods of <string> class to do this so I fallback on strlwr(). But the c_str() method returns a const...
4
by: Joanna Carter \(TeamB\) | last post by:
I would like to copy the contents of a Dictionary<string, object> to another Dictionary<string, object>. Do I have to iterate the source use something like foreach or is there an easier way ? ...
7
by: Wilson | last post by:
Hi, How do get the Dictioanry object from FiedlInfo ? my code : fieldInfo = this.GetType().GetField("dictioanry1"); ??Dictionary<string, string> dicTemp1 = (Dictionary<string,...
6
by: buzzweetman | last post by:
Many times I have a Dictionary<string, SomeTypeand need to get the list of keys out of it as a List<string>, to pass to a another method that expects a List<string>. I often do the following: ...
4
by: Mark Rae | last post by:
Hi, Is it possible to create a case-insensitive List<stringcollection? E.g. List<stringMyList = new List<string>; MyList.Add("MyString"); So that:
12
by: Mark S. | last post by:
Hello, The app in question is lives on a Windows 2003 server with .NET 2.0 running IIS 6. The page of the app in question processes 2000 get requests a second during peak loads. The app uses...
2
by: Assimalyst | last post by:
Hi I have a Dictionary<string, List<string>>, which i have successfully filled. My problem is I need to create a filter expression using all possible permutations of its contents. i.e. the...
0
by: Andy B | last post by:
Is there a way to databind a checkBoxList to a Dictionary<string, string> object? If so, how do you do it?
2
by: Andy B | last post by:
I don't know if this is even working or not but here is the problem. I have a gridview that I databound to a dictionary<string, stringcollection: Contract StockContract = new Contract();...
2
by: jandeerit | last post by:
hi... can anyone help to show me how to store the array in a dictionary object as shown below? FROM: Array : "PARAMETERS" : "ParamName-1" : "ParamValue-1" : "ParamName-2" ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.