TechNote

Number: 04502-06
Date: October 1994

Understanding DOS memory and memory managers

1.0 Introduction

Random Access Memory provides temporary storage for programs and data. It is the most volatile storage medium in your computer. Its contents are erased whenever you switch off the power. RAM exists on the main system board of your computer or on add-in memory boards. The more RAM you have, the more data you can store in it at one time. Henceforth we will refer interchangeably to Random Access Memory and memory. By the latter we do not mean hard or floppy disks.

Your DOS system might use as many as five kinds of memory. Although physically the same, these account for different areas of available RAM. This multiplicity reflects a history of attempts by developers to realize additional memory under the constraint of DOS's limited address range.

The different kinds of memory that you might use are as follows:

1.1 Conventional Memory

This type of memory is basic to all computers running DOS. Programs written for DOS can use Conventional Memory without the special instructions they need to use other types of memory.

Some of the available Conventional Memory is taken up by DOS. The device drivers and commands listed in your CONFIG.SYS and AUTOEXEC.BAT files use some too. Any that is left over is available for other programs.

1.2 Extended Memory (XMS)

Installing Extended Memory is the best way of adding more memory to your system. You can install Extended Memory on systems with 80286, or higher, processors. Most programs that use Conventional Memory cannot use Extended Memory. This is because the addresses that identify locations in Extended Memory are beyond the range of addresses that most programs can recognize.

All DOS programs can recognize addresses in the 640Kbytes of Conventional Memory, but not all can recognize addresses above this.

Most programs therefore need special instructions to recognize addresses in Extended Memory.

To use Extended Memory efficiently, you can install a program called an Extended Memory manager. This prevents different programs from using the same part of Extended Memory at the same time. DOS version 5.0 includes an Extended Memory manager called HIMEM.SYS (see Section 2.0). This conforms to the Lotus/Intel/Microsoft/AST eXtended Memory Specification (XMS).

Extended Memory is the best choice for memory expansion if you wish to use Microsoft Windows version 3.0 or above. (See Section 1.2.1).

1.2.1 Windows and Extended Memory: task-swapping

Unlike DOS, Windows operates by treating available RAM as undifferentiated "memory". It doesn't matter where in memory a Windows application runs. And for DOS applications, Windows can use available memory to create separate virtual-DOS machines. This means that each active DOS application effectively resides in its own area of Conventional Memory. It greatly facilitates multi-tasking: to effect a switch among DOS programs the processor does not need to unload the contents of Conventional Memory and load another program. It just addresses another area of memory instead.

1.3 Expanded Memory (EMS)

Most computers can accommodate Expanded Memory. This used to consist of two parts: an Expanded Memory board, which was installed on the computer, and a program called an Expanded Memory manager, which came with the board.

On 8086 computers Expanded Memory was the only way of increasing available memory. It was mainly used for storing data required by application programs; program code could not normally be run in Expanded Memory. Data would be mapped from an Expanded Memory board into space in the Upper Memory Area called a Page Frame. From the Page Frame it could then be accessed by an application program.

Today the concept of Expanded Memory describes software emulation of this process. If your computer has a 386 or higher processor with more than 1Mbyte of RAM, you no longer need to install an Expanded Memory board in order to use Expanded Memory. Expanded Memory Managers map data from Extended Memory into Page Frames as if your computer had Expanded Memory boards installed.

Expanded Memory is faster than Extended Memory but programs which use it can only access 16Kbyte blocks of data at a time (16Kbytes being the maximum size of a Page Frame). However, because Expanded Memory was introduced first, there exist more programs that are designed to use it than is true of Extended Memory.

Expanded Memory managers conform to the Lotus/Intel/Microsoft Expanded Memory Specification (LIM EMS).

1.4 Upper Memory Area

Immediately above the 640Kbytes of Conventional Memory, is an area of 384Kbytes called the Upper Memory Area. The BIOS uses some of this, but parts that are left unused by your system can be used for other data or programs. These unused parts are called Upper Memory Blocks.

You can free up more Conventional Memory by running certain device drivers in Upper Memory Blocks. The DOS commands DEVICEHIGH, and LOADHIGH, enable you to do this. They store driver code in an area of Extended Memory that has been mapped by a Memory Manager into Upper Memory. The number of drivers you can run using a Memory Manager depends on how much Upper Memory is left unused by your system and by your Expanded Memory Page Frame. The free space that is available for pieces of driver code must also be sufficiently unfragmented to accommodate them properly.

DEVICEHIGH and LOADHIGH are particularly useful for users of networked computers, because applications often do not take account of the need for network drivers to be accommodated when they make their own demands upon available memory.

1.5 High Memory Area

High Memory is a small amount of memory just above the 1Mbyte threshold, where you can run DOS itself. This frees up about 64Kbytes of Conventional Memory for use by application programs. If your system has more than IMbyte of RAM the DOS version 5.0 Setup program normally installs DOS so that it will automatically run in HMA. If for some reason you are not running DOS version 5.0 in HMA you can do so by adding the following commands to your CONFIG.SYS file:

device=himem.sys
dos=high.

2.0 DOS Memory Managers

To use your computer's Extended Memory, Expanded Memory, Upper Memory Area, or High Memory Area, you must install memory management software.

A memory manager is a device driver that provides access to a particular type of memory. The handling of Conventional Memory is part of DOS's normal operation, but extra software is required for memory management beyond this. DOS version 5.0 includes two installable memory managers:

Although memory managers themselves use some Conventional Memory, they make up for it by providing access to much larger amounts of Extended Memory, Expanded Memory, Upper Memory, or High Memory.

Further reading

Microsoft MS-DOS Version 5.0 User's Guide And User's Reference.