473,387 Members | 1,619 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,387 software developers and data experts.

Dictionary Throws OutOfMemoryException

I have an application that throws System.OutOfMemoryException when the
application has only allocated 1.3GB of RAM (according to the Task
Manager). I've repeated the operation several times and the exception
is thrown either when I'm calling Add or ContainsKey of a
System.Collections.Generic.Dictionary object with around 5.9 million
values (the size is different each time but around 5.9M each time).

The computer has 2 GB of physical RAM and runs Windows XP Pro. Virtual
memory is set to an initial 2GB with a maximum of 4GB of RAM. It is my
understanding that applications can have up to 2GB of addressable memory
in Windows XP Pro. What is going on here? Is this a limitation of the
Dictionary structure?
Nov 3 '06 #1
1 8001

"O.B." <fu******@bellsouth.netwrote in message
news:12*************@corp.supernews.com...
|I have an application that throws System.OutOfMemoryException when the
| application has only allocated 1.3GB of RAM (according to the Task
| Manager). I've repeated the operation several times and the exception
| is thrown either when I'm calling Add or ContainsKey of a
| System.Collections.Generic.Dictionary object with around 5.9 million
| values (the size is different each time but around 5.9M each time).
|
| The computer has 2 GB of physical RAM and runs Windows XP Pro. Virtual
| memory is set to an initial 2GB with a maximum of 4GB of RAM. It is my
| understanding that applications can have up to 2GB of addressable memory
| in Windows XP Pro. What is going on here? Is this a limitation of the
| Dictionary structure?

Your application can only address up to 2GB of memory, but this 2GB has to
be shared with the code, this means that you don't have 2GB to store data.
Note also that the underlying store of a Dictionary consists of two array's,
and arrays need contiguous storage. The way code modules are laid-out in
your address space restricts the largest size of contiguous memory to
something like 1.2 - 1.6 GB depending on the type of application. Note also
that you should initialize the dictionary to the size (in entries) you are
expecting (if at all possible), that way you prevent excessive fragmentation
and restrict the allocation of entries to what you effective need (well,
more or less , there is some % of free entries anyway). Note that it's
insane to allocate such huge containers and expect that you won't run out of
memory space when running on a 32 bit OS, you should change your design or
move to a 64 bit OS if this is not an option.

Willy.


Nov 3 '06 #2

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

Similar topics

4
by: Ryan Seghers | last post by:
I've got a program that has no user interface (like a service but not actually a Windows Service yet) in which I'd like to handle OutOfMemoryExceptions. I'd at least like to log the failure before...
0
by: Per Bergland | last post by:
After many woes, I finally managed to get a stack dump of my System Service (written in C#) that insists on crashing when launched at system boot time (see below on how to get this dump - I...
3
by: Michael | last post by:
I have a problem with catching the OutOfMemoryException in a managed C+ application. When creating small objects on the managed heap neithe the catch handler for OutOfMemoryException nor the...
1
by: Ripul Handa | last post by:
Hi We are running IIS 5.0 cluster with cisco local director. We are running a website on 2 webservers and I have been observing that from past few days we have are getting this error message of...
1
by: SMG - Idealake | last post by:
Hi all, I am getting following error on my error, what could be the reason? Exception of type System.OutOfMemoryException was thrown. Description: An unhandled exception occurred during the...
2
by: Dave | last post by:
We just started getting this error message in our application today (stack trace below). From the OutOfMemoryException, I'm guessing it could be a memory leak. I'm making sure I'm closing all my...
3
by: Anders Borum | last post by:
Hello! I am using Hashtables to cache data in services and am looking at generics for typed access (I control the key/value types). However, I was surprised to see that the Dictionary throws a...
6
by: Fao, Sean | last post by:
Is it possible to bind a GridView to a generic Dictionary object? When I try it in my ASP.NET application, it throws an exception acknowledging that the specified field or property does not exist....
6
by: sternr | last post by:
Hey, When I try to run the following code: System.Drawing.Image tiffImage = System.Drawing.Image.FromFile(@"C: \Image.tiff"); I get an "Out Of Memory" Exception. Does anybody know how...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.