The magazine of the Melbourne PC User Group

Memory optimising - Tutorial
George Skarbek
gskarbek@melbpc.org.au

The "Insufficient Memory" message from Windows 3.x is a common problem. Often I have been asked to help users who have lots of memory in their PC but receive this error message after opening only three or four applications. The incidences of this have sometimes been extreme. For example, a user of a 64 MB Pentium was told "Insufficient Memory" when merely attempting to open a fifth application. Memory management is also becoming quite a problem for some users whose laptops are connected to a LAN. With a laptop, after loading the card and socket services, and networking software, there can be limited base memory left and the "Insufficient Memory" message can occur after opening only a few applications.

Base Memory

The most important part of memory is base memory, namely the first 640 KB. How much of it is available, to a large extent, determines the behaviour of Windows. To eliminate the above mentioned problems, the fundamental strategy is to load as much as possible from CONFIG.SYS and AUTOEXEC.BAT into upper memory, which is different again to extended memory.

The program MEMMAKER can do an acceptable job of optimising memory, but relying on it has two drawbacks. One is that MEMMAKER must be run whenever any memory-resident programs are added by some software installation. Occasionally memory-resident programs or drivers are added by other programs, when new software or hardware is being installed. Adding a CD-ROM is a good example. The other drawback is that MEMMAKER will generally not do as good a job in optimising memory as a skilled operator could.

DIY and save

What follows is a description of how doing your own memory optimising can produce better results than relying on MEMMAKER. Before starting out you must make a copy of your AUTOEXEC.BAT and CONFIG.SYS files in case you are forced to undo all your changes. Also examine these files in case MEMMAKER has already been run, and remove all optimising that it performed. The optimising will be in the form of a command that starts with something like

LH /L:1;12345

in the AUTOEXEC.BAT file or a line that starts with

DEVICEHIGH

in CONFIG.SYS.

These lines must not be deleted, but should be returned to their original state, before MEMMAKER optimised them.

Making use of Upper Memory

The starting point for manual memory optimising is always from DOS, with Windows shut down, using the

MEM /C /P

command. To save the memory map to a file called M1, type

MEM/C >M1

Figure 1 shows the output from this MEM command on a computer that loads network drivers on starting.


Figure 1. Unoptimised starting point.

The largest executable program size shows that there is 536 KB of base memory free, which is not as good as it could be and is a long way short of the theoretical 640 KB available. This listing also shows that there are no free upper memory blocks into which programs can be moved. The important clue as to why, is the right-hand side, under the heading Upper Memory, which shows all zeros. This is caused by an inadequate entry in the CONFIG.SYS file in the line containing EMM386. The first part of CONFIG.SYS is

DEVICE=C:\DOS\HIMEM.SYS
DEVICE=C:\DOS\EMM386.EXE
DOS=HIGH,UMB
DEVICEHIGH=C:\DOS\SETVER.EXE
DEVICEHIGH=C:\DOS\ZANSI.SYS
DEVICEHIGH=C:\DOS\RAMDRIVE.SYS 16 /E
COUNTRY=044,,C:\DOS\COUNTRY.SYS
FILES=40
BUFFERS=10
LASTDRIVE=Z


By adding NOEMS to the second line to make it read:

DEVICE=C:\DOS\EMM386.EXE NOEMS

and then rebooting, the memory map in Figure 2 appears.


Figure 2. The first steps - after adding NOEMS and with some use of DEVICEHIGH

The files that can be moved high (into upper memory) are after the COMMAND entry in the top part of the memory dump and are taking up conventional memory. These programs should be loaded into memory from CONFIG.SYS and AUTOEXEC.BAT. To arrange this in CONFIG.SYS you must alter

DEVICE=

to read

DEVICEHIGH=

If the program is loaded from AUTOEXEC.BAT then add LH at the start of the line that refers to that program. Not every program can be run from upper memory, but most can. After making these small changes and rebooting, the result in Figure 3 is achieved.


Figure 3. Improvements following a little juggling

Now we have 618 KB of base memory and still 79 KB of free upper memory, with the largest block being 47 KB, into which we can load drivers for sound cards, tape backup units, etc.

If even more upper memory is required, to load more drivers or programs, then specific reserved blocks of upper memory can be included by instructing EMM386 to include an additional block of memory. The appropriate line in CONFIG.SYS has I=B000-F7FF added, as shown below:

DEVICE=C:\DOS\EMM386.EXE NOEMS I=B000-B7FF

This is the part of memory reserved by IBM for the monochrome adapter card, dating back from the early XT days. This block of memory is available on most computers and by utilising this gives results shown in Figure 4.


Figure 4. An even better "bottom Line".

We still have 618 KB of base memory and now we have 111 KB of free upper memory, with a largest block of 52 KB.

For comparison, using MEMMAKER, the bottom line was 585 KB of base memory with 47 KB free upper memory, and a largest free block of 33 KB.

Fine tuning

Further optimising can be achieved in cases where the largest free upper memory block is a bit smaller than the largest program left in conventional memory. The trick is to move the order in which programs are loaded, to put the largest ones first. However this is not always possible as some programs must be loaded in a certain order. If this is not possible, then leave out a smaller program to make room for a larger program to move up.

In this case, assume that the largest free block was 10 KB and that REDIR (13 KB) was not loaded high. I would remove the LH instruction from the PPORT program (4 KB) which should make 14 KB available for the 13 KB program to load high and get an improvement in base memory. This technique usually works, but will fail if some programs need more memory to load and initialise than the memory required to just run. A mouse driver is such an example.

Squeezing some more

Still more memory can be made available by including memory in the E000-EFFF range. However this only works on some computers and can lead to instability. But if you are pushed for memory, it is definitely worth trying. To see how much of this upper memory can be used use Microsoft's MSD program. This is menu driven and selecting the memory option will give you a memory map. Figure 5 contains a character-based output of what you will see.


Figure 5. A memory map from MSD

The important part here is the area in the E000 to EFFF range. In the example shown, the ROM occupies E000 to F7FF but E800 to EFFF (which are highlighted in bold) is shown as being free. This is not an absolute guarantee that it will be available, but it is well worth trying. Just add an additional include range in the EMM386 line as shown.

DEVICE=C:\DOS\EMM386.EXE NOEMS I=B000-B7FF I=E800-EFFF

If the computer boots it is still no guarantee that everything will work correctly but it is a good start. If the computer hangs during booting, hit the reset switch and press F8 during booting in order to single step during booting. This will enable you to view each line in CONFIG.SYS and say Yes or No to whether or not you wish to execute it. Say No to the EMM386 line.

Just because everything works well in DOS is no guarantee that Windows will work. With some Toshiba and all IBM Thinkpad laptops, Windows will not run if the B000-B7FF range is included. However with more base memory free, Windows will run faster and be able to have more programs simultaneously open.

The last drop

For those who are still desperate for more useable memory with Windows, I can strongly recommend a commercial product called Ram Doubler that sells for $100 and is very easy to install. Its name is misleading (it doesn't double memory) but it increases the System Resources, thereby largely eliminating the dreaded "Insufficient Memory" message. I have installed it on several dozen different computers and all work stably with no previous problems recurring. This product will only be useful for Windows users who have System Resources below about 25 percent. To check what your resources are, once you have loaded all your common programs, click on Help, About in the Program Manager. I have found Ram Doubler to be far more stable than QEMM 8.0, which can do more optimising for both DOS and Windows.

Conclusion

For a quick fix to the "Insufficient Memory" Windows problems you can spend $100 and not learn anything about memory management, or spend no dollars and run MEMMKAER to significantly improve your usable memory. However by spending some time in learning about memory management you can optimise your computer's memory and gain a lot of self satisfaction and knowledge. In this typical case, the available memory was increased from 536 KB to 618 KB and there still was 52 KB of upper memory available for loading device drivers such as a CD-ROM without making any impact on important base memory.

Reprinted from the September 1996 issue of PC Update, the magazine of Melbourne PC User Group, Australia

[About Melbourne PC User Group]