Top Navigational Bar

Practical Memory Management Guide - Troublesh
DocumentID: 613515
Revision Date: 29-Feb-96 1:35:45 PM

The information in this document applies to:
WordPerfect® 5.1 for DOS

Problem

Solutions: Practical Memory Management Guide
Charts Summary
Conventional PC memory is divided into space reserved for loading software and space reserved for hardware needs. Loading high is a way of taking extra unused hardware memory address space and converting it to software usage. Programs keep getting bigger and bigger, and the 640K originally allocated for running them keeps looking smaller and smaller. Loading high lets the user have more than 640K for loading programs. But the user must take great care to avoid creating software/hardware conflicts that will cause computer crashes. The include and exclude chart is a valuable tool for use with memory managers to eliminate conflicts that occur.

The Conventional Memory Map
Conventional memory is the entire first 1024K (1M) of memory addresses. It has two primary divisions: the bottom 640K is set aside for software use and the upper part is reserved for hardware use. The area reserved for hardware is also known as Upper Memory.

When the distinction between software and hardware space was first made, plenty of space was left over (the designers thought) for future expansion. As it has turned out, hardware's need for memory space has not grown as fast as expected, and software has gotten much bigger than anyone expected. But it's too late to redraw the boundary line between software and hardware: too much hardware and way too much software has been written to the old standard. By changing the boundary line we would no longer be able to use current hardware or software created to comply with this standard.

LoadHigh to the Rescue
"Loading high" is a clever way of temporarily redefining what is hardware space and what is software space, all the while remaining compatible with industry standards. If you have a 386 machine (or above), you can load high by using a memory manager such as EMM386.EXE or QEMM386.SYS, which can grab unused chunks of hardware memory and treat them as software memory. If you are careful, your hardware never has a clue you are poaching on its territory. If you are not careful, you will probably not be able to start your computer normally from your hard drive, and you will need a bootable floppy disk to get up and running so you can revise your foolhardy memory manager parameters. Still, most users can reclaim up to 200K of extra memory space for TSRs and device drivers that otherwise would crowd the bottom 640K.

Memory manager programs contain detection routines that try to automatically tell which areas of upper memory are safe for you to use. Their detection is good, but not foolproof, and just running a memory manager can sometimes lock your system after the manager does something like loading your mouse instructions on top of your network card instructions. Or, erring in the other direction, the manager may not detect all the space that is actually free, and thus not give you all the UMBs (Upper Memory Blocks) you are entitled to. Because of these problems, memory mangers allow you to override their detection choices and "Include" or "Exclude" areas of upper memory by hand. (See the examples below.)

Include/Exclude Chart
Segment (block) ranges (replace with A, B, C, D, E, F)

0-4K             000- 0ff
4-8K             100- 1ff
8-12K       200- 2ff
12-16K       300- 3ff
16-20K       400- 4ff
20-24K       500- 5ff
24-28K       600- 6ff
28-32K       700- 7ff
32-36K       800- 8ff
36-40K       900- 9ff
40-44K       a00- aff
44-48K       b00- bff
48-52K       c00- cff
52-56K       d00- dff
56-60K       e00- eff
60-64K       f00- fff

Memory manager example:
DEVICE=C:\WINDOWS\EMM386.SYS X=E000-E7FF I=E800-EFFF
eXclude memory range from use by memory manager
Include memory range for use by memory manager.

Once you understand how to understand and create Include and Exclude parameters on a memory manager line, you are 90% of the way to your attaining your MMG (Memory Management Guru).

Hexed...
Hexadecimal numbering is the standard way computers count up memory. Hexadecimal numbering uses 16 digits instead of the familiar 10 digits we are used to. In hex, not only are 0 through 9 used, but the "numbers" A, B, C, D, E and F are also counted after 9 is reached (see the chart below). When the odometer on your car turns over, it's at a 9. If it were a hexadecimal odometer, it would turn over after F, which is equivalent to decimal 15. Hex values get bigger faster than decimal values, so you can usually do in 4 digits of hex what it would take 5 digits of decimal to do.

Hexidecimal/Decimal Equivalency Chart
Hex
0      1      2      3      4      5      6      7      8      9      A      B      C      D      E F
Dec
0      1      2      3      4      5      6      7      8      9      10      11      12      13      14 15

Hex
10      11      12      13      14      15      16      17      18      19      1A      1B      1C      1D      1E 1F
Dec
16      17      18      19      20      21      22      23      24      25      26      27      28      29      30 31

Hex
20      40      80      9F      100      9FF      1000      9FFF            1000            A0000
Dec
32      64      128      255      256      4095      4096      65,535      65,536      655,360 (640K)

Hex
B0000      C0000      D0000      E0000      F0000      FFFFF      100000
Dec
720,896      786,432      851,968      917,504      983,040      1,048,575      1,048,576 (1M)

Hex has some other nice features as well. The first megabyte of memory divides up very neatly into sixteen hexadecimal blocks of 64K each (see the chart below), which each start at an even hexadecimal segment address: 1000, 2000, 3000...all the way up to F000 (pronounced F-thousand).

Conventional Memory Chart
      Usage            Decimal            Hexadecimal
F      ROM BIOS            960-1024K            F000-Ffff
E      Other Hardware      896-960K            E000-Efff
D      Other Hardware      832-896K            D000-Dfff
C      Other Hardware      768-832K            C000-Cfff
B      Video            704-768K            B000-Bfff
A      Video            640-704K            A000-Afff
9      Software            576-640K            9000-9fff
8      Software            512-576K            8000-8fff
7      Software            448-512K            7000-7fff
6      Software            384-448K            6000-6fff
5      Software            320-384K            5000-5fff
4      Software            256-320K            4000-4fff
3      Software            192-256K            3000-3fff
2      Software            128-192K            2000-2fff
1      Software            64-128K            1000-1fff
0      DOS/Software      0-64K            0000-0fff

Segments:Offsets are Really:Confusing
You have probably seen computer memory addresses that look like this: C000:1234.

This is a Segment:Offset address. The Segment side indicates the hexadecimal starting point of a 64K block of memory: a Segment. The Offset side tells how far into that block to count to find the actual address. A Segment:Offset address is thus actually two numbers that can be added together to generate an Absolute (Flat) address. The segmented address C000:1234 is equivalent to the flat address C1234:

C0000
+1234
C1234

Notice that an extra 0 was placed at the end of C000 to make it C0000 before adding the :1234. Segments addresses always have an implied 0 at the end of them. C000:1234 should be thought of as C000[0]:1234. Because of the implied zero, segments increment by 16 byte intervals; the Offset is thus needed whenever it is necessary to be able to count a single byte at a time. (By the way, to turn a 5-digit absolute memory address back into its segmented form, simply split off the first digit and insert three 0's and a colon: C1234 becomes C 1234 becomes C000:1234.)

Memory managers use segment addresses (4 digits) for defining memory ranges to Include or Exclude. They also omit the offset for the sake of brevity. So, if you see the address C000 on a memory manager line it means the same thing as C000:0000 which means the same thing as C0000, and all of them refer to the beginning of the C block in upper memory. Segment-only addresses are by far the most common way of listing memory addresses, and so you can assume that most 4 digit memory addresses are segment addresses, while 5 digit numbers mean flat addresses.

The reason for all this confusion has to do with a hardware limitation of the original PC. The 386 and 486 PCs don't have this limitation, but because DOS software is written to be backwards compatible with the original PC, we must still live with segmenting as long as we still use DOS.

The main thing you need to remember about this is that sometimes the address [n]000 is the same as [n]0000 for some reason.

Regional Differences
Memory Regions are numbered from 0 to 9. Region 0 is all memory below 640K. Regions 1 up to 9 are the blocks of memory that you have grabbed with a memory manager for your own use. If you include some space in B block, then skip C because it is being used by hardware, and then Include D block, your B Include becomes region 1 on your machine; the D block is region 2. Other people's regions might be very different from yours.

If you have DOS 6 (or most third-party memory managers), you can define by region where you load something high. This is useful because you may have little pockets of free space scattered throughout the user area, and deciding which little pocket a particular program loads in may allow you to fill them more completely.

Here's an example of what can happen if you can't control regions. Let's say the first program you want to load high takes 40K. But your first region is only 32K. The program can't load there so the memory manager looks next to region 2, which is, let's say, 64K in size. Enough room, so it loads there. Along comes your next TSR which is 8K. It would fit easily in the first region. But once the memory manager has skipped past that first region, it won't go back to fill it in unless you tell it to do so by a region switch in your load high command.

If you have DOS 5, you don't get any region control, and so you have to experiment with the order in which you load programs to fit the most you can into the upper memory area.

Sample CONFIG.SYS lines

Memory Manager Lines
DEVICE=C:\EMM386.EXE RAM
      EMM386 is the Microsoft memory manager that ships with DOS 5 and above and with Windows. It must be used in conjunction with HIMEM.SYS (DEVICE=HIMEM.SYS should be loaded before the EMM386 line.) You must also have the line DOS=HIGH,UMB or DOS=UMB in your CONFIG.SYS for EMM386 to be able to support loading high.
      RAM provides support for both loading high and expanded memory. This line will automatically create and place an expanded memory page frame, and automatically include and exclude the areas that EMM386 detects as free or not free to use in upper memory.

DEVICE=C:\EMM386.EXE NOEMS
      NOEMS provides support for loading high but not for expanded memory. This line will automatically include and exclude the areas that EMM386 detects as free or not free to use in upper memory, but not create or place an expanded memory page frame.

DEVICE=C:\EMM386.EXE RAM 1024 I=E000-EFFF FRAME=E000 X=C000-C7FF
      RAM provides support for both loading high and expanded memory.
      1024 allocates the amount of expanded memory, in K (default is 256).
      I=E000-EFFF includes the E block for use either loading high or for an expanded memory page frame. Prior to the version included with DOS 6, EMM386 did not automatically detect and include the E block for loading high, but always had to be told explicitly to include it.
      FRAME=E000 forces the 64K expanded memory page frame to load at the beginning of E block.
      X=C000-C7ff excludes the first half of C block from use for loading high or expanded memory.

DEVICE=C:\EMM386.EXE NOEMS X=B000-B7FF I=E000-EFFF I=F700-F7FF
      NOEMS provides support for loading high but turns off expanded memory.
      X=B000-B7FF excludes the first half of the B range.
      I=E000-EFFF forces include of the E block.
      I=F700-F7FF includes a small "ROMhole" found in the F block on a particular machine. ROMholes sometimes exist because many BIOS chips don't take up the full 64K they are allotted. There can be multiple Include or eXclude parameters on a memory manager line.

DEVICE=C:\QEMM386.SYS RAM NOEMS X=B000-B7FF I=E000-EFFF I=F700-F7FF
      This line does the exact same thing as the EMM386 example above. Quarterdeck's QEMM386.SYS memory manager uses X= and I= parameters just as EMM386.EXE does, and for normal purposes its command syntax is very similar. But note that NOEMS must be used along with, not in place of, the RAM parameter to provide support for loading high but turning off expanded memory. QEMM386.SYS and other third-party memory managers do not need HIMEM.SYS or DOS=UMB.

DEVICE=C:\386MAX\386MAX.SYS USE=E800-EFFF RAM=C000-C7FF,E000-E7FF
             EMS=0 VIDMEM=A000-C000 (end of first line)
      PRO=C:\386MAX\386MAX.PRO
      BCF=C:\MYBIOS.BCF
      Qualitas' 386 to the Max is another popular memory manager, but its syntax is considerably different than that of EMM386 or QEMM386. BlueMax is a version of 386 to the Max intended specifically for true blue IBM machines, and its syntax is nearly identical to 386 to the Max.
      RAM=C000-C7FF,E000-E7FF excludes the first halves of both C and E blocks, like the X= excludes. Multiple RAM and USE statements can be used, or single ones with memory ranges separated by commas.
      USE=E800-EFFF includes the last half of E block, like the I= to include.
      EMS=0 does the task of NOEMS, and also allocates the amount of expanded memory in K (for loading high) if the value is nonzero.
      VIDMEM=A000-C000 excludes A and B blocks. You cannot use the RAM parameter to exclude memory below C000 with 386 to the Max.
      PRO=C:\386MAX\386MAX.PRO defines a profile or configuration text file that may contain more command line parameters, or all the command line parameters.
      BCF=C:\MYBIOS.BCF defines a BIOS Compression File. If such a file exists, it contains information about which parts of the BIOS are discardable after bootup, thus allowing the BIOS to be "compressed" in memory. This parameter may be particularly important on a PS/2 machine, whose BIOS takes up both E and F blocks. Both the PRO= and BCF= parameters can be on separate lines or appended to the main 386MAX line in CONFIG.SYS.

Loading Drivers High

DEVICEHIGH /L:1=C:\DOS\ANSI.SYS
      The examples above were all of memory manager lines which configure memory in preparation for loading high. This line is the first example to actually load something high. If you are using Microsoft DOS 5 or DOS 6 memory managers (HIMEM/EMM386), DEVICEHIGH= is the command you substitute for DEVICE= to load something high in CONFIG.SYS. (In AUTOEXEC.BAT, you will use LOADHIGH.)
      /L:1 is the DOS 6 region switch, and tells ANSI to load in region 1. Region switches work only in DOS 6 if you are using EMM386. If you set a region switch, the program will load in the region defined, or in the next higher available region. Region switches can be used both in CONFIG.SYS and AUTOEXEC.BAT, and have the same syntax in both places.

DEVICE=C:\QEMM\LOADHI.SYS /R:1 C:\DOS\ANSI.SYS
      This line does the same thing as the example above, but for Quarterdeck's QEMM memory manager. One difference between the standard Microsoft memory managers and third-party memory managers is that Microsoft commands to load things high are built in to DOS, while the third-party manager commands are actual program files in their own right.
      /R: is QEMM's region switch.

DEVICE=C:\386MAX\386LOAD.SYS PRGREG=2 PROG=C:\DOS\ANSI.SYS
      PRGREG=2 is 386 to the Max and BlueMax's region parameter, and this line would load ANSI in region 2.

Sample AUTOEXEC.BAT Loading High

LOADHIGH C:\MOUSE\MOUSE.COM or LH C:\MOUSE\MOUSE.COM
      This loads the mouse high if you are using standard Microsoft memory managers. LH is interchangeable with LOADHIGH for nearly all intents and purposes. Remember that you only need a mouse driver like mouse.com if you run DOS programs that do not have their own mouse drivers. Most WPCorp products have their own, as does Windows.

C:\QEMM\LOADHI.COM C:\MOUSE\MOUSE.COM
      QEMM uses LOADHI.SYS in CONFIG.SYS and LOADHI.COM in AUTOEXEC.BAT. To specify region, see the CONFIG.SYS example. By the way, third-party memory managers have almost as many confusing parameters available for their load high lines as for their memory manager lines. Ignore them in the same way.

C:\386MAX\386LOAD.SYS PROG=C:\MOUSE\MOUSE.COM
      This is 386 to the Max and BlueMax's load high line. To specify region, see the CONFIG.SYS example.

Memory Manager Tips
-      Never experiment with Include parameters without having a bootable floppy disk ready.
-      Don't edit customer's memory manager lines: REM the old ones, and create new ones.
-      Turn off expanded memory to get 64K of extra memory for loading high that would otherwise be hogged by the expanded memory page frame, if you simply need more conventional memory and don't care about using expanded memory.
-      Don't let the huge lists of complicated memory manager parameters alarm you: If you understand how to exclude and include ranges, how to create/kill expanded memory, and how to specify regions, you know what you need to know. Almost all the other parameters deal with hardware compatibility issues or do memory tricks that most people who want a stable, compatible system soon learn to leave alone. The use of these other parameters is a support issue for the maker of the memory manager, not WPCorp. If a customer's need for free conventional memory cannot be satisfied by excluding or including memory and turning off expanded memory, then his system configuration is complicated enough that what he really should be looking for is a high-priced local computer consultant, not toll-free telephone support for a word processor.
-      The goal in configuring the upper memory is to get the largest contiguous block (region) for loading high that you possibly can. Having one large block is far more useful (and easier to work with) than having several smaller blocks, even if the smaller blocks add up to more memory overall. If a network card or expanded memory page frame is in the middle of what might otherwise be an unbroken block of memory, try to move it up or down, preferably without annoying it.

Utilities
The DOS MEM.EXE is a basic resource in discovering what has been loaded where. At a DOS prompt, type MEM/C|MORE to see which resident programs are loaded low or high and how much memory you have available. (Without DOS=UMB in CONFIG.SYS, MEM won't show you information about the upper memory area. Third-party memory managers have their own utilities for displaying this information.)

MSD.EXE, which ships with Windows 3.1, is a very good system snooper, and its memory section will help you find out what is available to you in the reserved memory area when you are trying to write Include and eXclude statements.

Some Hardware Quirks
Many VGA cards have a video BIOS extension at C000 that often runs all the way to C7ff. This ROM is usually easily detected, and almost any memory manager will exclude it properly. But if your machine has VGA and doesn't have this extension, you may have to manually include it, because the way some memory managers "detect" this ROM is to always assume it is there. (Many Epson 386's have their video BIOS extension at E000 rather than C000.)

Compaq machines often have "split ROM," which for the purposes of loading high means little chunks (4K or so) of ROM scattered around the upper memory area. Some memory managers are "Compaq aware" and handle this just fine; with others you may have to do some detective work.

The area from B000-B7ff is reserved for mono video. If you have a VGA card and do not plan to use mono video modes, you can often include this extra 32K area for loading high. Some Super-VGA cards will not allow you to use the mono video area: they grab it back at random times while you are working for no other reason than to make you crazy. If you have included this area, and start experiencing "random" locking, try un-including it by removing the I=B000-B7ff.

PS/2 machines have a more sophisticated than normal BIOS and it sprawls over both the E and F blocks. Some memory managers (BlueMax, specifically) will "compress" this BIOS and return the E block to you, but it's usually a good idea to be wary of including E block on PS/2 computers.

Network cards tend to be difficult to detect; it's a good idea to know in advance exactly what memory your card owns and exclude it yourself rather than trusting a utility to figure it out.

On generic clone systems which do not have add-on cards like scanners or networks, the entire range from C800-Efff is often free, and you can make your customer think you are an absolute genius with a single include statement.

Hands-on Memory Management

Target Practice
Write an EMM386 line that creates support for both expanded memory and loading high, and which includes the first half of the B block while excluding both the last half of the D block and the first half of the E block.

Write an EMM386 line that turns off support for expanded memory but still supports loading high, and which includes the entire E block.

On your own machine, configure your memory so that according to MEM.EXE you have 600,000+ bytes for "largest executable program size." You must load your network drivers and a disk cache (such as SMARTDRV) for it to count.

Answer:

Details:


Product specifications, packaging, technical support and information (*Specifications*) refer to theUnited States retail English version only. Specifications for other versions may vary. All Specifications, claims, features, representations, and/or comparisons provided are correct to the best of our knowledge of the date of publication, but are subject to change without notice.OUR MAXIMUM AGGREGATE LIABILITY TO YOU AND THAT OF OUR DEALERS AND SUPPLIERS IS LIMITED. IT SHALL NOTEXCEED THE AMOUNT YOU PAID TO ACCESS THE INFORMATION. SEE LEGAL DISCLAIMER.