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

c# out of memory question

I am trying to run a c# program which loads very large arrays (total
of about 1.2GB). I have 2GB of RAM on my machine and looking at task
manager it doesnt look like it has all been used. I have set virtual
memory (ie disk space to be used as RAM) to 3070MB. I have tested my
RAM using a RAM testing utility and it seems fine. I am getting an out
of memory error.

I started by using visual c# 2002 but someone told me that it was
buggy so I swithced to visual c# express...but no help. I cut the
program down to a very simple test version...which follows. Are ther
any setting I can change on my PC or within c# to get this to work?

here is the code:
using System;

namespace test1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class testmain
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
try {
testclass testclass1 = new testclass();
}
catch {
int yyy=4;
}
}
}
class testclass {

double [] frogarray;
double [] frogarray1;

public testclass() {
frogarray = new double[150100000];
frogarray1 = new double[50000];
int aaa=3;
}
}
}

Nov 25 '06 #1
4 13872
I have reproduced the error using Visual Studio 2005. The largest array I
can allocate is about 110,000,000 of double (= 880,000,000 bytes). I can't
get 120,000,000 (= 960,000,000 bytes).

It seems reasonable to suppose that, in 32-bit Windows, the memory used by a
running application is limited to 1 GB, and part of that is of course your
program and the .NET Framework.

Here's some discussion:
http://www.dotnet247.com/247referenc...55/276803.aspx

Apparently we've found the Achilles' heel of .NET Framework. For a
workaround, see the remarks about editbin and LARGEADDRESSAWARE near the
bottom.
<pb*****@covad.netwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
>I am trying to run a c# program which loads very large arrays (total
of about 1.2GB). I have 2GB of RAM on my machine and looking at task
manager it doesnt look like it has all been used. I have set virtual
memory (ie disk space to be used as RAM) to 3070MB. I have tested my
RAM using a RAM testing utility and it seems fine. I am getting an out
of memory error.

I started by using visual c# 2002 but someone told me that it was
buggy so I swithced to visual c# express...but no help. I cut the
program down to a very simple test version...which follows. Are ther
any setting I can change on my PC or within c# to get this to work?

here is the code:
using System;

namespace test1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class testmain
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
try {
testclass testclass1 = new testclass();
}
catch {
int yyy=4;
}
}
}
class testclass {

double [] frogarray;
double [] frogarray1;

public testclass() {
frogarray = new double[150100000];
frogarray1 = new double[50000];
int aaa=3;
}
}
}

Nov 25 '06 #2
Hey Michael
Thanks so much for your help on that...it seems like the first real
progress Ive made on this in DAYS!!
One more thing ...it says that I need to enter the linker option
through the property pages tab. Unfortunately, this is greyed out..and
does nothing when I click it...any ideas on this one?

Michael A. Covington wrote:
I have reproduced the error using Visual Studio 2005. The largest array I
can allocate is about 110,000,000 of double (= 880,000,000 bytes). I can't
get 120,000,000 (= 960,000,000 bytes).

It seems reasonable to suppose that, in 32-bit Windows, the memory used by a
running application is limited to 1 GB, and part of that is of course your
program and the .NET Framework.

Here's some discussion:
http://www.dotnet247.com/247referenc...55/276803.aspx

Apparently we've found the Achilles' heel of .NET Framework. For a
workaround, see the remarks about editbin and LARGEADDRESSAWARE near the
bottom.
<pb*****@covad.netwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
I am trying to run a c# program which loads very large arrays (total
of about 1.2GB). I have 2GB of RAM on my machine and looking at task
manager it doesnt look like it has all been used. I have set virtual
memory (ie disk space to be used as RAM) to 3070MB. I have tested my
RAM using a RAM testing utility and it seems fine. I am getting an out
of memory error.

I started by using visual c# 2002 but someone told me that it was
buggy so I swithced to visual c# express...but no help. I cut the
program down to a very simple test version...which follows. Are ther
any setting I can change on my PC or within c# to get this to work?

here is the code:
using System;

namespace test1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class testmain
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
try {
testclass testclass1 = new testclass();
}
catch {
int yyy=4;
}
}
}
class testclass {

double [] frogarray;
double [] frogarray1;

public testclass() {
frogarray = new double[150100000];
frogarray1 = new double[50000];
int aaa=3;
}
}
}
Nov 25 '06 #3
Hello pb*****@covad.net,

I think you can set the linker option alternatively using EditBin utility
as mentioned there.

Read more about it here,
http://msdn2.microsoft.com/en-us/library/xd3shwhf.aspx

Share your results then,

Jigar Mehta
http://jigar-mehta.blogspot.com
Hey Michael
Thanks so much for your help on that...it seems like the first real
progress Ive made on this in DAYS!!
One more thing ...it says that I need to enter the linker option
through the property pages tab. Unfortunately, this is greyed out..and
does nothing when I click it...any ideas on this one?
Michael A. Covington wrote:
>I have reproduced the error using Visual Studio 2005. The largest
array I can allocate is about 110,000,000 of double (= 880,000,000
bytes). I can't get 120,000,000 (= 960,000,000 bytes).

It seems reasonable to suppose that, in 32-bit Windows, the memory
used by a running application is limited to 1 GB, and part of that is
of course your program and the .NET Framework.

Here's some discussion:
http://www.dotnet247.com/247referenc...55/276803.aspx
Apparently we've found the Achilles' heel of .NET Framework. For a
workaround, see the remarks about editbin and LARGEADDRESSAWARE near
the bottom.

<pb*****@covad.netwrote in message
news:11*********************@j44g2000cwa.googlegr oups.com...
>>I am trying to run a c# program which loads very large arrays (total
of about 1.2GB). I have 2GB of RAM on my machine and looking at task
manager it doesnt look like it has all been used. I have set virtual
memory (ie disk space to be used as RAM) to 3070MB. I have tested my
RAM using a RAM testing utility and it seems fine. I am getting an
out of memory error.

I started by using visual c# 2002 but someone told me that it was
buggy so I swithced to visual c# express...but no help. I cut the
program down to a very simple test version...which follows. Are ther
any setting I can change on my PC or within c# to get this to work?

here is the code:
using System;
namespace test1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class testmain
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
try {
testclass testclass1 = new testclass();
}
catch {
int yyy=4;
}
}
}
class testclass {
double [] frogarray;
double [] frogarray1;
public testclass() {
frogarray = new double[150100000];
frogarray1 = new double[50000];
int aaa=3;
}
}
}

Nov 25 '06 #4

<pb*****@covad.netwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
|I am trying to run a c# program which loads very large arrays (total
| of about 1.2GB). I have 2GB of RAM on my machine and looking at task
| manager it doesnt look like it has all been used. I have set virtual
| memory (ie disk space to be used as RAM) to 3070MB. I have tested my
| RAM using a RAM testing utility and it seems fine. I am getting an out
| of memory error.
|
| I started by using visual c# 2002 but someone told me that it was
| buggy so I swithced to visual c# express...but no help. I cut the
| program down to a very simple test version...which follows. Are ther
| any setting I can change on my PC or within c# to get this to work?
|
| here is the code:
| using System;
|
| namespace test1
| {
| /// <summary>
| /// Summary description for Class1.
| /// </summary>
| class testmain
| {
| /// <summary>
| /// The main entry point for the application.
| /// </summary>
| [STAThread]
| static void Main(string[] args)
| {
| try {
| testclass testclass1 = new testclass();
| }
| catch {
| int yyy=4;
| }
| }
| }
| class testclass {
|
| double [] frogarray;
| double [] frogarray1;
|
| public testclass() {
| frogarray = new double[150100000];
| frogarray1 = new double[50000];
| int aaa=3;
| }
| }
| }
|

Each process on Windows can allocate 2GB of Virtual Address Space (VAS),
however, this memory range is also used to load your code modules, the CLR
run-time modules, the native Win32 process heaps, thread stacks etc.
Loading of these modules (DLL's) at process creation time, results in a
fragmented VAS, such that only a part of the 2GB VAS is free for data
allocations (such as the GC heap).
A small console application (as you posted), NOT running in VS or in a
debugger, should have at least 1.6 GB of *contigious* memory available [1],
this means that this *exact* code should run. Note that all depends on the
OS and the version of the CLR and the type of program, here I'm talking
about XP SP2 and the v2 CLR and the program you posted, other OS versions
may load the modules at different addresses and other type of appications
may load more modules (think Windows.Forms).
Applying the 3GB switch and patching the exe (using editbin) such that it
becomes /LARGEADDRESSAWARE isn't of great help, all you get is an extra 1GB
of memory, but this one is separated from the other free block of memory in
the process, so, the largest contigious block of memory stays the same.
Note that you should never assume you will have that huge (say 1GB) amount
of *contigious* memory available on 32 bit a OS, if this is what you are
after you should move to a 64 bit OS.
Willy.

[1]
This should work when running from the commandline, on XP with V2 of the
framework.

frogarray = new double[200000000]; // ~1.600.000 Bytes
frogarray1 = new double[500000]; // another ~400.000.000 Bytes
Nov 25 '06 #5

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

Similar topics

32
by: John | last post by:
Hi all: When I run my code, I find that the memory that the code uses keeps increasing. I have a PC with 2G RAM running Debian linux. The code consumes 1.5G memory by the time it finishes...
6
by: Fred Zwarts | last post by:
Hello, I am trying to debug some complex debug code. In order to track the use of dynamically allocated memory, I replaced the standard global new and delete operators. (Not for changing the...
20
by: Jonas | last post by:
Hi, I'm 99 % sure that Standard C guarantees to do a memory move inside realloc() in case the new, returned memory block (address) is different than the original one. Can any C expert confirm...
8
by: vikram | last post by:
i have series of questions 1.How a c program is loaded in memory i mean the whats is the structure that the code segment?? data segment?? 2.When you say const int *p; where is p...
30
by: jimjim | last post by:
Hello, This is a simple question for you all, I guess . int main(){ double *g= new double; *g = 9; delete g; cout<< sizeof(g)<<" "<<sizeof(double)<<" "<<sizeof(*g)<<" "<<*g<<" "<<endl; *g =...
18
by: Ramasubbu Ramasubramanian XR (AS/EAB) | last post by:
What is memory leakage, could any one explain with sample code
25
by: Zeng | last post by:
I finally narrowed down my code to this situation, quite a few (not all) of my CMyClass objects got hold up after each run of this function via the simple webpage that shows NumberEd editbox. My...
2
by: Ashish | last post by:
hi all, I have been doing some performance testing of a asp_net website, to be hosted on a shared server .. as far as i understand every page when accessed first time is compiled and loaded in...
7
by: toton | last post by:
Hi, I have a STL vector of of characters and the character class has a Boost array of points. The things are vector<Characterchars; and class Character{ private: array<Point,Npoints; }; Now...
9
by: Hemal | last post by:
Hi All, I need to know the memory required by a c program. Is there any tool/utility which can give me the memory usage in terms of DATA segment, TEXT segment, BSS segment etc. I am working...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.