473,657 Members | 2,486 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dictionary Throws OutOfMemoryExce ption

I have an application that throws System.OutOfMem oryException 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.Collecti ons.Generic.Dic tionary 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 8041

"O.B." <fu******@bells outh.netwrote in message
news:12******** *****@corp.supe rnews.com...
|I have an application that throws System.OutOfMem oryException 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.Collecti ons.Generic.Dic tionary 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
4328
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 exiting, if possible. I understand that it probably takes some memory to continue operating, even just to write a message to an open file, but if the allocation that triggered the OutOfMemoryException was large then there probably really is a...
0
2768
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 couldn't find any info on how to do this). Here's the stack trace from cordbg: Unhandled exception generated: (0x04719c94) <System.Runtime.Remoting.RemotingException> _className=<null> _exceptionMethod=<null>
3
5987
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 UnhandledExceptio handler is called in an out of memory situation. Instead the applicatio writes 'Fatal out of memory' to the console and exits Is this a bug in the runtime or am I missing something Here is the example code #include "stdafx.h...
1
3440
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 and on Error Messag Remote IP:66.122.242.6 Host:216.211.212.2
1
4975
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 execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.OutOfMemoryException: Exception of type System.OutOfMemoryException was thrown.
2
3938
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 connections in the finally block but I'm not sure what I should be doing. As far as the "Unable to serialize the session state" error, this app has been running for days and this is the first I've seen this one as well. Any thoughts would be...
3
50534
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 KeyNotFoundException if you try to reference missing keys, which is a change from the Hashtable. So what? Well, the idea of a cache is to ensure high performance (low latency) access
6
29190
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. The problem, I think, is that the GridView cannot see "inside" of the generic Dictionary. I suspect this because setting the AutoGenerateColumns property of the GridView causes the GridView to display only the Key property, which is, of...
6
6653
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 can I overcome this problem?
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8726
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8603
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7320
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.