Overview of the Windows 95 Virtual Address Space Layout

Last reviewed: September 25, 1995
Article ID: Q125691
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows 95 version 4.0
    

SUMMARY

The virtual memory management mechanism in Microsoft Windows 95 makes it possible to execute Win32-based, 16-bit-based, and MS-DOS-based applications simultaneously. To accomplish this, the virtual memory manager uses a virtual address space layout that is considerably different from that used by Microsoft Windows version 3.x and that is slightly different from that used by Microsoft Windows NT. Although the differences from Windows NT are slight, they are important.

The memory manager in Windows 95 uses paging and 32-bit linear addressing to provide a full 32-bit virtual address space that has a maximum size of four gigabytes (GB). This four-GB address space is partitioned by the memory manager into four major sections, known as arenas, that are used for different types of applications and parts of the system. The first arena, from zero to four megabytes (MB) exists for compatibility with applications based on Windows version 3.1x and MS-DOS. The next arena, from four MB to two GB, is the private address space for each Win32 process. The third arena, from two to three GB, is a shared address space that contains memory mapped files and the 16-bit components. Finally, the fourth arena, from three to four GB, is reserved for the system's use.

MORE INFORMATION

The following diagram shows the overall virtual address space layout used in Windows 95. The Compatibility Arena holds the current virtual machine and other software. Each Win32 process gets its own private address space in which to execute. The Private Arena contains the currently executing Win32 process's private address space. All 16-bit-based applications and DLLs, including the 16-bit Windows system components, reside in the Shared Arena. Finally, the Reserved System Arena is used to store all ring-0 code such as the virtual machine manager and virtual device drivers. It is not accessible by either 16-bit-based or Win32-based applications.

        +---------------------------------+ 4 Gigabytes
        |                                 |
        |      Reserved System Arena      |
        |    (Holds ring-0 components)    |
        |                                 |
        |---------------------------------| 3 Gigabytes
        |                                 |
        |          Shared Arena           |
        |                                 |
        |                                 |
        |---------------------------------| 2 Gigabytes
        |                                 |
        |         Private Arena           |
        |    (Holds address space of      |
        |      currently executing        |
        |         Win32 process)          |
        |                                 |
        +---------------------------------+ 4 Megabytes
        |           16-bit/MS-DOS         |
        |        Compatibility Arena      |
        +---------------------------------+ 0 Gigabytes

Each arena has a specific purpose and is described in detail below.

16-bit/MS-DOS Compatibility Arena

The first four megabytes of the system's address space is reserved by the system and is accessible to 16-bit and MS-DOS software for compatibility. The current virtual machine occupies the lowest megabyte of this area. The remaining three megabytes are mostly empty space but may contain MS-DOS device drivers and Terminate & Stay Resident (TSR) programs.

The 16-bt/MS-DOS Compatibility Arena is not accessible to Win32 processes for reading or writing. This means Win32 processes may may not allocate memory, load DLLs, or be loaded below the four megabyte (MB) address.

Private Arena

The private arena holds the private address space of the currently executing Win32 process. Because every Win32 process gets its own address space, the contents of this arena will depend upon which process is currently executing. The memory manager maps the pages of a process's private address space so that other processes cannot access it and corrupt the process. The process's code, data, and dynamically-allocated memory all exist in the private address space.

With the exception of the system's shared DLLs (USER32.DLL, GDI32.DLL, and KERNEL32.DLL), all DLLs loaded by the process are mapped into the process's private address space. Windows extension DLLs such as SHELL32.DLL, COMCTL32.DLL, and COMDLG32.DLL are not system shared DLLs and are mapped into the process's private address space.

Because console applications are Win32-based applications without graphical user interfaces, they too get their own private address spaces, as do Win32 graphical user interface (GUI) applications.

The minimum load address for a Win32 process in Windows 95 is four MB because the first four megabytes are reserved for the Compatibility Arena.

Shared Arena

The shared arena is unique to Windows 95. This arena contains components that must be mapped into every process's address space. All of the pages in this arena are mapped identically in every process.

The 16-bit global heap, which contains all 16-bit-based applications, DLLs, and 16-bit system DLLs, resides in the shared arena. The Win32 shared system DLLs (USER32.DLL, GDI32.DLL, and KERNEL32.DLL) are also located in the shared arena.

Unlike the Reserved System Arena, the shared arena is readable and writable by Win32 and 16-bit processes alike. This doesn't mean they are free to get memory directly from this address space. All 16-bit-based applications and DLLs actually are located in the 16-bit global heap, so they allocate memory from the 16-bit global heap; when this heap needs to be grown, KRNL386.EXE gets the memory from the shared arena.

Win32 processes may not allocate memory directly from the shared arena, but they always use it for mapping views of file mappings. Unlike Windows NT, where views of file mappings always are placed in the private address space, Windows 95 holds views of file mappings in the shared arena.

The DOS Protected Mode Interface (DPMI) server's memory pool is located in the Shared Arena. Thus, calls to the DPMI server to allocate memory will result in memory that is globally accessible.

Sometimes, a virtual device driver (VxD) may need to map a buffer passed to it by a Win32 process into globally accessible memory so that the buffer can be accessed even if the process isn't in context. By calling _LinPageLock virtual machine manager service with the PAGEMAPGLOBAL flag, a VxD can obtain a linear address in the shared arena that corresponds to the buffer passed to it by the Win32 process.

Reserved System Arena

The reserved system contains the code and data of all ring-0 components such as the virtual machine manager, DOS extender, DPMI server, and virtual device drivers. This arena is used exclusively by ring-0 components and not addressable by ring 3 code, such as MS-DOS-based, 16-bit-based, and Win32-based applications and DLLs.


Additional reference words: 4.00 layout memory virtual
KBCategory: kbprg
KBSubcategory: BseMm


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 25, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.