Team LiB
Previous Section Next Section

Chapter 7: Memory Management

Virtual Memory and Address Space

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:

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:


Team LiB
Previous Section Next Section