30.06.2013 Views

Under the Hood of .NET Memory Management - Simple Talk

Under the Hood of .NET Memory Management - Simple Talk

Under the Hood of .NET Memory Management - Simple Talk

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 7: The Windows <strong>Memory</strong> Model<br />

Virtual memory uses a combination <strong>of</strong> physical, RAM-based memory and disk-based<br />

memory to create a uniform virtual memory address space. Combining <strong>the</strong> two resources<br />

into a single pool gives applications access to a far larger and, as far as processes are<br />

concerned, homogenous memory space. In Figure 7.1 you can see a Virtual Address Space<br />

(VAS) made up <strong>of</strong> a sequence <strong>of</strong> memory blocks, or pages, which point to ei<strong>the</strong>r physical<br />

or disk-based memory.<br />

Figure 7.1: Process Virtual Address Space.<br />

Pages<br />

The virtual memory address space is organized into chunks, or pages, and <strong>the</strong>re are two<br />

types <strong>of</strong> pages (you can specify page size in VirtualAlloc):<br />

• small (4 KB)<br />

• large (16 MB).<br />

When a chunk <strong>of</strong> memory is requested by <strong>the</strong> .<strong>NET</strong> runtime, a set <strong>of</strong> virtual pages,<br />

sufficiently large to accommodate <strong>the</strong> requested size, are allocated. If you asked for 9 K,<br />

you would get three pages at 4 K each, that is, 12 K in total.<br />

199

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!