0

I always had this question that where (RAM / HARD DISK / some other (?) ) is the Heap located ?

if i load a 2 GB file via code in memory then where will it go ?

Also where is this "stack" located in physical place ? RAM ?

Can someone from actual implementation team can let us know this ? because what most people says is its RAM . But i wanted to really really know where and how both ? Please share some good articles if it's difficult to answer it here .

trincot
  • 317,000
  • 35
  • 244
  • 286
Dhananjay
  • 3,673
  • 2
  • 22
  • 20
  • No need fo the miplementation team. Heap and Stack are standard things beginner low level probgrammers must know - that is beginners working on low level assembler style programming. – TomTom Mar 20 '12 at 12:08

4 Answers4

2

I would recommend reading the following article:

http://blogs.technet.com/b/markrussinovich/archive/2008/11/17/3155406.aspx

The .NET heap is just a part of your application's user address space. So whether it (and all objects allocated in it) is currently in RAM or on disk depends on the current memory pressure of the whole system and the VMM's decisions. Also parts of the heap can be in RAM and other parts on disk at the same time.

2

What and where are the stack-and-heap

This question and its answers explains it in very great detail. It covers both, the stack and the heap. How its used, the differences etc. It also has nice graphics!

Community
  • 1
  • 1
Alex
  • 7,901
  • 1
  • 41
  • 56
0

When you run a .NET exe, it loads MSCorEE.dll which will host the CLR. CLR will create stack and heap in the process memory. It will look after asking for more memory for the process if it needs it.

They will be located in RAM, although operating system will abstract it from you (e.g. it could be on a swap file).

Aliostad
  • 80,612
  • 21
  • 160
  • 208
0

if you load 2GB file memory of .NET process it will crash on 32bit system, as the framework approximately holds 1.2GB on 32bit systems.

The memories you're talking about are in RAM for .NET managed assemblies. For others, due the possible memory swapping, made by OS itself in low RAM memory conditions, could partialy finish on Disk space.

Tigran
  • 61,654
  • 8
  • 86
  • 123