Windows Support Menu
Windows 95 virtualizes memory just as it virtualizes machines and drivers. This memory virtualization allows each program to behave as if the program had its own physical RAM.
Virtual memory is the way a program views memory.
Each program is allocated a unique virtual address space, which is a set of addresses available for the program to use. Every 32-bit Windows-based and Microsoft MS-DOS̉-based program is allocated its own virtual address space. Programs access the memory through their virtual addresses that are mapped by the Windows 95 memory manager onto physical addresses. These physical addresses may point to locations in RAM or on the hard disk.
In Windows 95, the operating system can allocate more memory than is physically available on the workstation. Windows 95 offers virtual memory using the demand-paging capabilities of the Intel 80386 or higher processor. Program code and data in physical memory can be swapped into a specially created swapfile on the hard disk.
The swapfile changes size with the needs of the system. If hard drive space is running low, the size of the swapfile is decreased. If hard drive space is available and more memory is required, the size of the swapfile is increased.
Each address space is divided into 1,048,576 (220) pages. Each page is 4K in size. Physical memory is allocated on a per page basis. A page may indicate memory that is located somewhere in RAM (the actual location may be changed by the system), in a swapfile on a disk, or marked as unused. If the page is indicated as unused, the address exists but physical memory is not allocated.
The Virtual Memory Manager maps virtual addresses in the process's address space to physical pages in the computer's memory or swapfile. In doing so, it hides the physical organization of memory from the program. This ensures that the threads can access its process's memory as needed, but not the memory of other processes.
Swapping in and out is controlled by the Windows Virtual Memory Manager. The virtual memory manager performs paging and maintains a list of 4K pages currently in physical memory by accessing a page table. The page table tells Windows which pages are swapped to disk, which belong to which process, and so on.
Windows 95 allocates each Virtual Memory space 4 GB of memory addresses. This is address space only, 4 GB of physical memory is not required. The memory addresses are mapped out as follows.
When a virtual address points to a page that is not in physical memory (that is, the referenced page is stored on the hard disk), the processor generates a page fault. The page fault signals the Virtual Memory Manager to load the page from disk into memory; this is called a page-in. If there is not enough free memory available to fit the page, then the Virtual Memory Manager must swap a page out of memory and store it on disk; this is called a page-out.
The system is designed for a certain amount of paging. However, if paging happens frequently a point can be reached where the system is doing so much paging that there is little time left for useful work. Excessive paging (or disk thrashing) degrades overall system performance and can also cause premature hard disk failure.
Generally, the solution to excessive paging is to add more RAM to the computer or to work with fewer programs simultaneously.