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

What is up with .NET memory usage?

It is common knowledge that 32-bit processes can use up to 2GB of RAM.
This has been my experience with native (vb6, c++) apps. However, .NET
apps tend to crash with Out of Memory errors whenever they approach 1.6
to 1.7 GB of RAM. Is the rest of the memory space between 1.7 GB and 2
GB is taken up by the runtime? 300mb? That cannot be since I've seen
winform apps run (not fast, but still) on systems with 128mb.

And if you set your app to be large address aware (e.g. to see up to
3gb) , it will crash at about 2.4gb to 2.6gb.

Is there a good explanation for this?
Jan 24 '07 #1
3 5341
I think memory occupied by OS and other applications should also be
considered.

The amount of memory space available depends on the above factors also.

Thanks
-Cnu.

On Jan 24, 11:36 am, Frank Rizzo <n...@none.netwrote:
It is common knowledge that 32-bit processes can use up to 2GB of RAM.
This has been my experience with native (vb6, c++) apps. However, .NET
apps tend to crash with Out of Memory errors whenever they approach 1.6
to 1.7 GB of RAM. Is the rest of the memory space between 1.7 GB and 2
GB is taken up by the runtime? 300mb? That cannot be since I've seen
winform apps run (not fast, but still) on systems with 128mb.

And if you set your app to be large address aware (e.g. to see up to
3gb) , it will crash at about 2.4gb to 2.6gb.

Is there a good explanation for this?
Jan 24 '07 #2
Hello Frank,

there are 2 reasons
1) The memory (.net heap) is reserved by segmemts wich size is 32/64 mb
2) memory can be fragmented, so even you have 1gb of free memory you may
have no free block with the size of 32mb - only number of block less then
32, so u got this exception

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
FRIt is common knowledge that 32-bit processes can use up to 2GB of
FRRAM. This has been my experience with native (vb6, c++) apps.
FRHowever, .NET apps tend to crash with Out of Memory errors whenever
FRthey approach 1.6 to 1.7 GB of RAM. Is the rest of the memory space
FRbetween 1.7 GB and 2 GB is taken up by the runtime? 300mb? That
FRcannot be since I've seen winform apps run (not fast, but still) on
FRsystems with 128mb.
FR>
FRAnd if you set your app to be large address aware (e.g. to see up to
FR3gb) , it will crash at about 2.4gb to 2.6gb.
FR>
FRIs there a good explanation for this?
FR>
Jan 24 '07 #3
"Frank Rizzo" <no**@none.netwrote in message news:eU**************@TK2MSFTNGP05.phx.gbl...
It is common knowledge that 32-bit processes can use up to 2GB of RAM. This has been my
experience with native (vb6, c++) apps. However, .NET apps tend to crash with Out of
Memory errors whenever they approach 1.6 to 1.7 GB of RAM. Is the rest of the memory
space between 1.7 GB and 2 GB is taken up by the runtime? 300mb? That cannot be since
I've seen winform apps run (not fast, but still) on systems with 128mb.

And if you set your app to be large address aware (e.g. to see up to 3gb) , it will crash
at about 2.4gb to 2.6gb.

Is there a good explanation for this?


This has been discussed a billion times before, a regular process has 2GB of memory space
available, but this memory is/can get fragmented. That means that the largest chunk of
memory your application can allocate equals the largest block of free memory.
Now if you take a look at the Virtual Address Space at the *start* of a .NET program (but
exactly the same applies to any Win32 process) it should look something like this:

0x00000000 - 0x01xxxxxxx Reserved for your application image(s) CLR workspaces and stack
space (1MB per thread)
0x01xxxxxxx - 0x02xxxxxxx Initial GC heap (generational and LOH)
0x02xxxxxxx - 0x5xxxxxxxx Free memory (the GC heap expands into this area)
0x5xxxxxxxx - 0x6yyyyyyyy Space (fragmented) taken by a number of DLL's (like gdiplus.dll
used by Windows Forms)
0x6yyyyyyyy - 0x7xxxxxxxx Free memory (the GC heap expands into this area)
0x7xxxxxxxx - 0x7FFFFFFF Space (fragmented) taken by runtimes (CRT, CLR and system
DLL's)
----- Next is for /4GT tuned systems
0x80000000 - 0x80010000 64 KB barrier - cannot be used.
0x80010000 - 0xBFFFFFFF Free memory

So, a 2GB VAS starts with a free space of ~1.2GB + ~500MB, depending on the number of DLL's
loaded and their base load addresses.
For a 3GB "Large Address Aware" process, you have ~1.2GB + ~500MB plus an extra ~1GB free
area, but still the largest area is ~1.2GB, that means that the largest CLR object (an
array) is limited to ~1.2GB.
But there is more, each memory segment (used to load a DLL or an heap segment) must start at
a 64KB boundary. that means that the space at top of VAS (0x7xxxxxx) where all DLL's are
mapped is largely fragmented, the free space between the mapped dll's is in general too
small to be allocated as process heap space and will never be used as GC heap space anyway.
The same is true for the space between 0x5xxxxxxxx - 0x6yyyyyyyy, the size of this area,
highly depends on the the number of mapped DLL's their base locations, which on their turn
depend on the type of application the version of the OS it's language version and the
language version of the application.

Willy.
Jan 24 '07 #4

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

Similar topics

3
by: Ian | last post by:
Hi all, I have a problem. I have an application which needs to work with a lot of data, but not all at the same time. It is arranged as a set of objects, each with lots of data that is created...
3
by: ianstirkcv | last post by:
Hello, I wonder if you can please help… We are running a web application built using .net framework version 1.0, service pack 2, running on Windows 2000 server, service pack 3. The server has...
5
by: Justice | last post by:
Currently I'm doing some experimenting with the XMLHTTP object in Javascript. Now, the XMLHttp object is asynchronous (at least in this case), and the following code causes a significant memory...
20
by: Philip Carnstam | last post by:
How come .Net applications use so much memory? Every application I compile uses at least 10 MB of memory, even the ones consisting of only a form and nothing else. If I minimize them though the...
8
by: GeekBoy | last post by:
I understand the benefit of pushing the StateServer process onto another computer to "balance" the load and take some cpu and memory usage off the web server, but how much could it possibly help?...
4
by: Ethan Chan | last post by:
I have recently been deploying a asp.net extranet application. The asp.net worker process starts off with 30MB virtual memory and then upon serving a few pages, the memory usage increases to a...
15
by: dee | last post by:
Hi, What is the maximum number of minutes for Session timeout that I can specify in web.config? Thanks. Dee
3
by: bamapookie | last post by:
I am new to VB, but not new to programming. I am using VB.Net 2003 and I have written a small app to monitor several running processes and everything is fine except the memory usage. When the app...
1
by: yzghan | last post by:
Hi all, I feel that my python script is leaking memory. And this is a test I have: log.write(" " + "test() ... memory usage: " + " ".join(repr(i/(1024*1024)) for i in getMemInfo()) + "\n") m...
2
by: manojmohadikar2008 | last post by:
Hi All, We are observing a serious issue with the memory usage of Queue and its very critical issue which needs to be fixed. We have an application which runs two threads i.e. a Producer and a...
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: 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
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?
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
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...

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.