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

.NET OutOfMemoryException

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.

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.OutOfMemoryException 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 3621
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.com> 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.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.

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.OutOfMemoryException 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/cpconinteroperatingwithunmanagedcode.asp?frame=tru e

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
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...
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...
1
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...
13
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...
8
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...
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
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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,...

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.