In Intel-compliant systems running Windows NT, Windows 2000, or Windows XP, programmers use virtual memory to access physical memory. In these systems, each process is given 4GB of virtual memory that maps to either the physical memory or the paging file. This virtual memory is split into two parts: user mode, which is the low 2GB (0x00000000 to 0x7fffffff) of memory, and kernel mode, which is the high 2GB (0x80000000 to 0xffffffff) of memory. For the most part, applications are written to operate in user mode, and drivers are written to operate in kernel mode. We will focus on user mode memory, since this is where most C# endeavors will operate.
In user mode address space (0x00000000 to 0x7fffffff), the memory of most applications is split into several parts:
There is process information block, which contains data about the process.
There are one or more thread environment blocks, which contain data that describes a thread.
There is at least one block of memory that is used as the default heap.
Finally, there is memory set aside to load assemblies such as executables (EXEs) or dynamic link libraries (DLLs).
Under the hood, the use of virtual memory allows for items like assemblies to be loaded into physical memory once, and then each process will map its virtual memory to the same physical memory. This greatly reduces the amount of memory used, since the DLL or EXE is loaded into physical memory only once.
Virtual memory comes in one of three flavors:
Free memory Memory that has not been requested for use in the virtual memory of the application. You may not use or access free memory.
Reserved memory Memory that has been set aside for an application but has not been committed, and thus there is no backing to the memory in pagefile.sys.
Committed memory Memory that has been reserved and does have space allocated in the pagefile.sys. You may not use reserved memory until it is committed. Fortunately, the operating system does this process for you, unless you want to get down and dirty with API calls to methods such as VirtualAlloc.