Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
In My Project When I Compiled "System.out of memory Exception" is Always Throwing.
In My System It Is 2gb RAM and 160GB hard disk. In c drive available space is there.
Is it the hard ware problem or my project Problem.
Please answer it.
Thanks.
Posted 6-Nov-11 23:12pm
JBSAHU1K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Your RAM and HDD space are not playing big role in your above excpetion.
Make the code worthy that deal with proper memory managment.
 
check following points in your code to avoid memory leaks
 
1. Close your connection after you have used it.
2. Close all Datareaders after you have used
3. Make NULL all dataset after used.
4. dispose your all object.

 
May be your darareaders are open in your project.
 
Change your code and check the effect.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try this
http://support.microsoft.com/kb/820108[^]
[Edit]
Oops, my bad. I thought you cannot use more than 2 GB. Still you can check your code and make it more memory efficient so that it works smoothly.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Quote:
In a normal 32 bit windows app, the process only has 2GB of addressable memory. This is irrelevant to the amount of physical memory that is available.
 
So 2GB available but 1.5 is the max you can allocate. The key is that your code is not the only code running in the process. The other .5 GB is probably the CLR plus fragmentation in the process.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Not sure about your code. Did you dispose the things properly?
 
Check these
 
IDisposable.Dispose Method[^]
using Statement (C# Reference)[^]
The "using" Keyword in C#[^]
Dispose and Finalize with C++/CLI, C# and VB[^]
When and How to Use Dispose and Finalize in C#[^]
 
And a sample thread found in SO which contains similar issue so that would be useful for you.
Out Of Memory exception on System.Drawing.Image.FromFile()[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

Check that you are building a 64-bit process, and not a 32-bit one, which is the default compilation mode of Visual Studio. To do this, right click on your project, Properties -> Build -> platform target : x64. As any 32-bit process, Visual Studio applications compiled in 32-bit have a virtual memory limit of 2GB.
 
Each process has its own virtual memory, called an address space, into which it maps the code that it executes and the data it manipulates. A 32-bit process uses 32-bit virtual memory address pointers, which creates an absolute upper limit of 4GB (2^32) for the amount of virtual memory that a 32-bit process can address. However, the operating system requires half of it (to reference its own code and data), creating a limit of 2GB for each process. If your 32-bit application tries to consume more than the entire 2GB of its address space, it will return “System.OutOfMemory”, even though the physical memory of your computer is not full.
 
64-bit processes do not have this limitation, as they use 64-bit pointers, so their theoretical maximum address space is 16 exabytes (2^64). In reality, Windows x64 limits the virtual memory of processes to 8TB. The solution to the memory limit problem is then to compile in 64-bit.
 
However, object’s size in Visual Studio is still limited to 2GB, by default. You will be able to create several arrays whose combined size will be greater than 2GB, but you cannot by default create arrays bigger than 2GB. Hopefully, if you still want to create arrays bigger than 2GB, you can do it by adding the following code to you app.config file:
 
<configuration>
<runtime>
<gcAllowVeryLargeObjects enabled="true" />
</runtime>
</configuration>
  Permalink  
Comments
Ron Beyer at 26-Jun-13 10:33am
   
Why are you resurrecting a 2 and a half year old question?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 575
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,476
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,917


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 26 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100