Memory issue, process termineted

P

prakashdehury

Hi,


I have a c# console exe
Based on input it consumes arround 1-3 gb of memory
I am trying to run it on win2003 box with 8GB of ram.

Once the consumed memory goes beyound 1 GM the process get termonated.
Am not sure if it is terminated by OS or by something security
settings of .Net.

Can anybody suggest what could be the reason.

Thanks in advance.
Dev
 
M

Marc Gravell

Well, there is a 2GB limit on the size of a process in Win32. You can
up this slightly using the /3GB switch
http://blogs.msdn.com/oldnewthing/archive/2004/08/13/214117.aspx

However, another big issue is what you memory looks like inside the
process - i.e. are you trying to allocate huge arrays? If so,
fragmentation will be a major issue, that could trigger an
OutOfMemoryException, presumably crashing your app.

Another consideration is: are you using your memory effectively? Hard
to tell without a /lot/ of info, though.

You could switch to Win64, but note that this changes the equation;
each reference has a larger footprint. If you have a huge array of
structs this is probably fine. If you have a huge array of objects (or
just a lot of references generally) your memory consumption will jump
yet further. But the process will have more space, so it is a double-
edged sword.

Marc
 
W

Willy Denoyette [MVP]

Hi,


I have a c# console exe
Based on input it consumes arround 1-3 gb of memory
I am trying to run it on win2003 box with 8GB of ram.

Once the consumed memory goes beyound 1 GM the process get termonated.
Am not sure if it is terminated by OS or by something security
settings of .Net.

Can anybody suggest what could be the reason.

Thanks in advance.
Dev


Seems like you are running on W2K3 32 bit, that means that the maximum
amount of memory available to a process is ~2GB. The largest contiguous area
of free memory in such process space is ~1.5GB, so whenever you try to
allocate an array of that size you are at risk to get an out-of-memory
exception thrown on you.
The question is why do you allocate that much memory, in the first place?

Willy.
 
M

Marc Gravell

For the OP's benefit - note also that the CLR places a 2GB limit on a
single object, which again limits the size of (for example) huge
arrays. And for an array of object-references (not structs) note that
of course the maximum number of items will shrink as the size of each
reference goes up (using 64bit over 32bit). But in most cases these
limits [process and object] are purely academic - it is quite rare for
an app to need more than this.

Marc
 
W

Willy Denoyette [MVP]

Marc Gravell said:
For the OP's benefit - note also that the CLR places a 2GB limit on a
single object, which again limits the size of (for example) huge
arrays. And for an array of object-references (not structs) note that
of course the maximum number of items will shrink as the size of each
reference goes up (using 64bit over 32bit). But in most cases these
limits [process and object] are purely academic - it is quite rare for
an app to need more than this.

Marc


Absolutely, note that the object size limit is also applicable on 64-bit
Windows, and even with the extremely large VAS on 64-bit, one can run into
OOM exceptions. You can never allocate more memory than the available free
virtual memory space (free RAM space + free pagefile space).

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top