How to manage memory with DOS 5.0. (MS-DOS Featuring DOS 5.0)
by Mark Minasi
DOS 5.0 has greatly expanded the range of things that DOS encompasses: data recovery through the UNDELETE and UNFORMAT programs, all-around user friendliness through the DOSSHELL program, general utilities via the DOSKEY command-history option, and new capabilities of MODE and other commands. It's a collection of utilities that would each cost from $20 to $50 or that you'd otherwise have to download from a bulletin board, worrying all the time about viruses.
But perhaps the greatest value of DOS 5.0 is that it finally unlocks some of the memory-management power of the 286 and 386 chips. The new DOS 5.0 memory-management commands--being part of a package that sells for as little as $40--are almost as useful as the memory-management packages costing around $100, the familiar QEMM, NETRoom, and 386Max packages. Notice I said almost--the third party packages are more stingy with your memory and provide much better installation tools. But as part of a $40 package, the DOS 5.0 memory tools aren't bad.
Types of Memory
No matter how many times and article explains memory types, there's always a call for more explanation. Briefly, your PC can address many types of memory, depending on whether it's an 8088-, 80286-, or 80386-based computer. (For the purposes of this article, 80386 means any one of the 386 family: the 80386DX, 80386SX, 80386SL, 80486SX, or 80486DX. They all behave the same, with regard to software, except for speed.)
This gets a mite hairy, so understand--nobody planned this. What you're about to read is a series of short-term solutions that have become, well, long-term solutions.
The first stop is conventional memory, the memory situated in addresses between OK and 639K. It's universal in that all programs can use this relatively small area. Many programs are restricted to this area and are unable to address any other kind of memory. All computers have this conventional memory. All computers also have an ability to address memory from 640K to 1023K, but that area isn't available for user memory. It's needed for the use of the system--the video board requires some memory, and that memory uses the addresses from 640K through 767K.
Also, the system requires space for Read Only Memory (memory chips that contain important software) on add-in expansion boards; that memory goes in the space between 768K and 1023K. The area from 640K through 1023K is called the upper memory area (UMA) by Microsoft nowadays, but you'll also hear it referred to by its older name, the reserved area.
Then, in 1985, a new kind of memory board appeared called an expanded-memory board, a kind of memory also known as EMS (Expanded Memory Specification) or LIM (Lotus-Intel-Microsoft). It became popular because Lotus 1-2-3 version 2.1 and later versions could use expanded memory. Any kind of PC can use expanded memory, so long as it has the memory board to support it, or, as we'll see, a memory manager program. Expanded memory uses up 64K of memory addresses in the part of the reserved area between 768K and 959K for an EMS page frame. It can be anywhere in the 768K-959K range, but it's most commonly at 832K.
Meanwhile, 286 and later processor chips support memory beyond the 1023K address: 16 megabytes (MB) on a 286, 4096MB on a 386. That memory isn't ordinarily accessible to DOS or most DOS programs. That's why it gets a different name--extended memory. Again, few DOS programs can use extended memory.
286 Memory Management
As they're very different in their capabilities, the 286 and 386 chip families have different memory managers.
Since a 286 is a much less powerful chip than a 386, a 286 memory manager is somewhat limited in what it can do. The most significant feat that a 286 memory manager can do is create an extra 64K of memory manager can do is create an extra 64K of memory space for DOS, an area from 1024K through 1087K. DOS 5.0's HIMEM.SYS device driver can create this 64K memory area, called the HMA (High Memory Area), and the new CONFIG.SYS command DOS=HIGH can load about 45K of DOS into that area. The BUFFERS also go into that area. Limited though that is, it's nothing to sneeze at. Instead of getting about 580K free space after DOS (the number under DOS 3.3), you can see about 613K free space under DOS 5.0 with a 286. That leaves enough memory to load your network drivers and still have enough room to load WordPerfect 5.1. (Or you can just buy LANtastic's LAN, which runs great on a small network and only takes about 15K of overhead.)
So memory management on a 286 is simple--load the HIMEM.SYS driver first thing in your CONFIG.SYS and use the DOS=HIGH command to load DOS above 1024K. About the only stumbling block you may run up against is that a few computers require a somewhat different command sequence to access the HMA. There's a/MACHINE: parameter that can be used to tell HIMEM.SYS that you've got one of the oddball PCs; look up HIMEM.SYS in your DOS manual for more details.
386 Memory Management
On a 386 computer, a memory manager does two main things: (1) it makes more memory areas available to DOS, and (2) it makes a system's extended memory bahave like expanded memory. In addition, the DOS 5.0 memory manager can do the 286 trick of moving DOS high.
Remember the UMA? The area between 640K and 1023K is reserved for system use, but all of it isn't necessarily used. A memory manager fills the unused spaces, creating memory areas that DOS can fill with programs.
The other big feature of a 386 memory manager is limulation. If you have a computer that has lots of extended memory but you want to run a program that requires expanded memory, it would seem that you're stuck--unless you've got a program that temporarily converts extended memory into expanded memory. This is essentially the process of emulating LIM memory, leading to the term limulation.
How to Use a Memory Manager
A 386 memory manager, as it's more complex, involves more experimentation and adjustment in order to yield the most power for your PC.
There are three basic steps to using a memory manager:
1 Determine unused areas in the range from 768K through 959K.
2 Use the memory manager to fill in the unused areas with memory; these memory areas are then called upper memory blocks (UMBs).
3 Fill the UMBs with device drivers and TSR programs.
The first step is the worst step, in terms of complexity. Recall that the upper memory area from 640K through 1023K is populated by memory of various types used by various hardware in your system.
The idea with a 386 memory manager is that it should be able to ferret out the used and unused areas, fill up the unused areas with memory (memory taken from your extended memory, for those who are wondering), and ignore the used memory areas.
The problem is that it's not a simple task. Sometimes the memory manager fillsin an area that's being used by your system's hardware, causing something--the video board, the hard disk, whatever--to misbehave, seemingly crash, or refuse to function altogether. Other times, the memory manager overlooks a memory area that's perfectly usable.
The memory manager under DOS 5.0 is a combination of two programs: HIMEM.SYS, which we already met in its role in the 286 world, and EMM386.EXE. The simplest invocation of the DOS 5.0 memory manager might look like this.
DEVICE=HIMEM.SYS DEVICE=EMM386.EXE RAM X=A000-BFFF I=E000-EFFF DOS=HIGH,UMB
The parameters after EMM386 instruct it to create upper memory blocks but to exclude the areas from A000 to BFFF (640K to 767K decimal), which are taken up by the video board, and to include the area from E000 to EFFF (896K to 959K decimal), which for some reason EMM386 always overlooks unless you specifically tell it not to. The DOS=HIGH,UMB instructs DOS to load itself above 1023K, as before, and to get ready to use the UMBs that the memory manager has created.
The memory manager has created the upper memory blocks. Now you've got to fill them. You can fill them with device drivers--anything loaded with the DEVICE= statement in your CONFIG.SYS--or with memory-resident programs (also known as terminate-and-stay-resident or TSR programs). Doing that is simple with two new DOS commands: DEVICEHIGH and LOADHIGH.
Here's a simple CONFIG.SYS from a PC running DOS 3.3.
DEVICE=C:\WINDOWS\HIMEM.SYS BUFFERS=30 FILES=30 DEVICE=C:\DOS\ANSI.SYS DEVICE=C:\WINDOWS\SMARTDRV.SYS 512
This is for a PC that runs Windows 3.0, hence the HIMEM--that's an older HIMEM, the one that ships with Windows. Under DOS 5.0, it might be improved like this.
DEVICE=C:\DOS\HIMEM.SYS DEVICE=C:\DOS\EMM386.EXE RAM X=A000-BFFF I=E000-EFFF DOS=HIGH,UMB BUFFERS=30 FILES=30 DEVICEHIGH=C:\DOS\ANSI.SYS DEVICEHIGH=C:\DOS\SMARTDRV.SYS 512
The UMBs are set up, and ANSI and SMARTDRV have been set up in high memory. Note that this CONFIG.SYS draws from the DOS subdirectory for HIMEM, not the WINDOWS directory. I've talked to several people who have been confused about which HIMEM should be used under DOS 5.0. Use the one that comes with DOS 5.0, at least until Windows 3.1 ships.
The LOADHIGH statement is easy to use. It goes in the AUTOEXEC.BAT in front of any existing TSRs. For example, I use DOS 5.0's DOSKEY command-history utility to recall previous commands. Rather than just put DOSKEY in my AUTOEXEC.BAT, as I would have for earlier versions of DOS, I put LOADHIGH DOSKEY (it can be abbreviated LH DOSKEY) in my AUTOEXEC.BAT. I get to use the utility without losing precious conventional memory. Some TSRs or device drivers won't load high. If you get strange behavior from your PC when you load your favorite programs high, call the program's vendor; some programs just plain don't work in UMBs.
Now that memory management has come to the masses via DOS 5.0, it's just plain crazy not to use the power of your 286- or 386-class PC to reclaim some memory for DOS. Dig in and give it a try!