473,804 Members | 3,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.NET OutOfMemoryExce ption

Hi all,

We have written a C # .NET application and we're
encountering memory problems in the form of
System.OutOfMem oryException.

Our application creates many thousands of objects in a
temporary in memory store, which uses a lot of runtime
memory. Not an ideal situation, but an acceptable short
term solution given our project constraints.

This works well for almost all size data inputs to the
software. However, on the very largest input datasets the
number of objects in the temporary store pushes the amount
of memory used on our test machine to it's physical limit.
After this point we would expect it to go into virtual
memory, but instead a System.OutOfMem oryException is
thrown, even though there is 4Gb of virtual memory
available. Other programs, such as Notepad, can use all
the virtual memory should they need to.

There should be no contention for virtual memory as the
software is running from an 'exe' on the c: drive and all
of our paging is on a separate dedicated disk (the d:
drive).

Can anyone suggest a way of ensuring that our .NET
application can access virtual/paging memory?

many thanks,
Peter
Nov 22 '05 #1
2 3681
I'm sure that there is nothing in .net which stops it from using VM
properly. You could try writing a test harness that just allocates loads of
memory to verify this.

Here's the only thing I can think of, which is something I have seen before
on a (non-dotnet app) that used a lot of memory:

If you allocate and free a lot of memory, It is possible you could fill the
address space up, so although there is virtual memory available, the 32-bit
address space is does not have big enough gaps to allocate the memory range
you need.

not sure how to get round this in .net though :(
"Peter Aberline" <pe***@willis.c om> wrote in message
news:00******** *************** *****@phx.gbl.. .
Hi all,

We have written a C # .NET application and we're
encountering memory problems in the form of
System.OutOfMem oryException.

Our application creates many thousands of objects in a
temporary in memory store, which uses a lot of runtime
memory. Not an ideal situation, but an acceptable short
term solution given our project constraints.

This works well for almost all size data inputs to the
software. However, on the very largest input datasets the
number of objects in the temporary store pushes the amount
of memory used on our test machine to it's physical limit.
After this point we would expect it to go into virtual
memory, but instead a System.OutOfMem oryException is
thrown, even though there is 4Gb of virtual memory
available. Other programs, such as Notepad, can use all
the virtual memory should they need to.

There should be no contention for virtual memory as the
software is running from an 'exe' on the c: drive and all
of our paging is on a separate dedicated disk (the d:
drive).

Can anyone suggest a way of ensuring that our .NET
application can access virtual/paging memory?

many thanks,
Peter

Nov 22 '05 #2
Hi Peter,

Thanks for your post. I'd like to share the following information with you:

1. Under .NET environment, the CLR requires that all resources be allocated
from a area of memory called managed heap. It is the common language
runtime's garbage collector that manages the allocation and release of
memory for a .NET application. We do not have much control over managed
heap and it will be automatically expand as you use more memory. Please
refer to the following article for detailed information on GC:

Garbage Collection: Automatic Memory Management in the Microsoft .NET
Framework
http://msdn.microsoft.com/msdnmag/is...I/default.aspx

Garbage Collection Part 2: Automatic Memory Management in the Microsoft
NET Framework
http://msdn.microsoft.com/msdnmag/is...2/default.aspx

2. I suggest you to use .NET Memory Profiler to check the memory usage of
both managed heap and native memory in your process.

NET Memory Profiler
http://www.scitech.se/memprofiler/

Please keep in mind that the 4GB process's virtual address space consists
of 2 GB user-mode, and 2 GB reserved as system memory. That is, 2GB
user-mode virtual address space can be used by an application. If your
system is Windows 2000 Advanced Server, Windows 2000 Data Center, or
Windows NT 4.0 Enterprise, you can increase it to 3GB by appending the /3GB
switch to the desired entry in your system's BOOT.INI file and check
whether or not the problem still exists.

3. In addition, you may consider creating unmanaged components and interop
with your managed application.

Interoperating with Unmanaged Code
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconinteropera tingwithunmanag edcode.asp?fram e=true

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 22 '05 #3

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

Similar topics

2
764
by: Peter Aberline | last post by:
Hi all, We have written a C # .NET application and we're encountering memory problems in the form of System.OutOfMemoryException. Our application creates many thousands of objects in a temporary in memory store, which uses a lot of runtime memory. Not an ideal situation, but an acceptable short term solution given our project constraints.
4
4343
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
2782
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
6010
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
3455
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
4996
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
3948
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...
1
3900
by: Ashkan Daie | last post by:
Hi All, When trying to install a performance counter via InstallUtil I get the following exception: Creating performance counter category Enterprise Library Caching. An exception occurred during the Install phase. System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was
13
12957
by: Venkatachalam | last post by:
Hi, In my application I have text(flat) file as input and I have to generate an XML file. The maximum input text file size can be 900MB and gererated xml may result 2+ GB. Based on the first column value from the text file, the row will be moved to any of those 23 DataTable which are created onfly. For eg. 01;- data for Table 1-
8
12575
by: =?Utf-8?B?UGlnZ3k=?= | last post by:
Hi to all, I am getting this System.OutOfMemoryException calling the Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(<stream>,<Obj>) method. The type of <streamis IO.MemoryStream =====Exception: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
0
9704
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
9569
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10558
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
10318
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
10302
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
10069
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
9130
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...
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2975
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.