Re: c# out of memory question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




<pberent@xxxxxxxxx> wrote in message
news:1164471409.799317.32490@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|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


.



Relevant Pages

  • Re: QRe: VMWare (GSX or ESX) VS Win4Lin
    ... > to find out whether it works better is to load more RAM and install multiple ... its memory consumption. ... running Rose and loading a large model - it takes ... a LONG time to load that model. ...
    (comp.os.linux.misc)
  • Re: c# out of memory question
    ... Hey Michael ... I have 2GB of RAM on my machine and looking at task ... memory to 3070MB. ... testclass testclass1 = new testclass; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: c# out of memory question
    ... I have 2GB of RAM on my machine and looking at task ... memory to 3070MB. ... testclass testclass1 = new testclass; ... double frogarray; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Will upgrade 2 Gigs of RAM help my Windows XP Pro?
    ... of more memory becomes a burden to the system in that it has to be ... > Manager stats on no load and full load: ... > to 2 Gigs of RAM? ... >> upgrade to 2 Gigs of RAM? ...
    (microsoft.public.windowsxp.hardware)
  • Re: Best Practice questions
    ... Exchange server because memory manager uses two PTEs to map every page of memory when the PAE kernal is enabled. ... So, if you have more than 4GB of RAM, all the tuning you did is for naught; ... If you have more than 4GB RAM installed in an Exchange 2003/Windows 2003 server, the PAE kernal will load unless you jump though a convolted and confusing series of hoops to prevent it. ...
    (microsoft.public.exchange.admin)