I'm not very good at remembering faces which can be embarrassing at times. I have on many occasions been stopped by people in the street who obviously know me and asked some quite technical question. Afterward I wander down the road thinking 'who the hell was that?'

I have no idea why I should be so bad at faces, but it seems to me most people have difficulty at remembering some things but not others. There are probably a number of people who could explain all about memory and why some of us can't remember certain things. But - I have a theory. It's not a very good theory and I expect most of you could find holes in it, but I l ike it. And by an amazing coincidence my theory also fits in with what I want to talk about this month. :-)

My theory is that we only have a small amount of short term or conventional memory, although we have a lot of long term storage. Since we have a limited amount of conventional memory we have make sure that we configure it properly ie put stuff we don't need very often into long term storage. In my case my brain has decided that remembering faces is not very important and so it has bunged all the faces into long term storage. Then when people stop me and ask questions I'm to busy thinking about their problem to recall their faces from my long term storage. See I told you it was amazing :-)

Just as, according to my theory, you have to configure your memory in order to get it to work best, so you must configure the memory on your PC. The thing is that trying to sort out memory on a PC can appear to be a daunting task. However, in practice it does not take much to make a big difference and what I would like to do this month is explain how you can better organise your memory.

Thanks for the Memory

When the IBM Personal Computer first came out it was a pretty good specification machine. Not, perhaps the best but it was made by IBM and hence immediately became the standard. At that time a lot of micro-computers had 64 Kilobytes of memory and used cassette tape for storage. The real power users did have floppy disk drives which were quicker than tape but not always as reliable. Then the IBM PC came out. The top of the range machine had 640 Kilobytes of memory, a floppy disk drive and a 20 Megabyte hard disk. This was real power user stuff, and there was no way any one was going to need more. Well not in the near future, say 15 to 20 years or so.

Have you ever noticed that there is one thing which is 100% reliable. It never fails, ever. And anyone can use it with out any training at all. It's called Hind Sight. Looking back now it's obvious that micro-computers would evolve and grow. It was also obvious that sooner or later we would need a lot more memory and disk storage than was available. What was not so obvious was the speed at which the changes came. But, none of that would have mattered except for one thing, which none of us could have anticipated. The success of the IBM PC.

The exact number of PC's in the world to day is not known but most estimates put it at around 60 million. This very success has caused a number of problems, mainly in ensuring that any new hardware or software is compatible with what came before.

This backwards compatibility has caused a number of problems with Dos it self. Ideally Dos should be thrown away and a new operating system written from scratch. Both IBM, with OS/2 and Microsoft with Windows 95 have tried to do this, but in both cases they also needed to make sure that Dos programs would run. Thus while both OS/2 and Windows 95 are nice operating systems they are big, bulky and don't work as well as they should do. For example one of the main selling points of OS/2 and Windows is their ability to run more than one program at the same time, known as multi-tasking. The thing is that the Macintosh and even the 'lowly' Amiga have been able to do that for many years and with a lot less hardware.

One of the drawbacks of Dos is the way it uses memory. [By the way when I talk about memory I mean Ram and Rom and not disk storage. I mention this 'cos I know that some people can get confused since both use the same units.] When the IBM PC was developed the CPU chosen was the Intel 8086. This processor was capable of addressing a 'massive' 1 megabyte, which was far more than anyone would ever need. Thus when Dos was written it was decided that 360 kilobytes of memory, between the 640 Kb mark and the 1 Mb mark, would be reserved for system use. This left 640 Kb available for programs. An amazing 10 times or more than people had been used to.

At first 640 Kb was enough, but before long people started to see what could be done and then they wanted more. This meant that programs had to get bigger, and soon the programmers were hitting the 640 Kb barrier. By now we had moved on from the 8086 to the 80286, more commonly referred to as the 286, and the 386 [actually the 80386 but who's counting]. These processors were capable of using much more than 1 Mb of memory and naturally the programmers wanted to use it. The trouble was that Dos had nicked this 360 Kb area and further more didn't even know that there was more.

The other problem with memory was that in practice the full 640 Kb was never available. Most people had various programs loaded in memory all the time. These included things like keyboard drivers, pop up calendars and diaries and so on.

It wasn't long before programmers started looking around to see if they could find some more memory somewhere. The first thing they looked at was the bit between 640 Kb and 1 Mb, which now a days is called the Upper Memory Area. They noticed that a lot of this area was unused most of the time and so they came up with various memory managers which were designed to make use of this area. These memory managers allowed you to put things like your Keyboard drivers in the upper memory area, thus leaving more room for your programs.

The next area they looked at was the memory above 1 Mb, which is known as Extended Memory or XMS for short. While the CPU's in use by then were capable of accessing this extended memory the motherboards were not. Therefore three of the big players in the PC industry at that time, Lotus, Intel and Microsoft got together and came up with a method of adding memory using an expansion board. This method was known as the Lotus, Intel, Microsoft Expanded Memory Specification or LIM EMS. Needless to say this quickly got abbreviated to EMS.

Nowadays all the memory is stored on the motherboard. That is the memory above 1 Mb is all Extended memory or XMS. However, some programs still use Expanded memory so some or all of the XMS can be configured to be EMS. Confusing isn't it?

Time for a diagram:-

Simple Memory Map

For those of you who would like a more detail there is a bigger table here.

So to summarise, we have conventional memory which is below 640 Kb. The Upper Memory area, which is between 640 Kb and 1 Mb and the rest, which can be either Extend or Expanded or both.

Now, you may think that since we now have access to the memory above 1 Mb our memory problems are over. If you need more memory all you have to do is buy some.

Right?

Wrong.

The problem is that Dos is still restricted to the 1 Mb region and it still needs the area above 640 Kb for the system. This effectively means that all your programs must fit within the 640 Kb limit. Once they are loaded they can make use of the bit above 1 Mb but the main program must fit below 640 Kb. This incidentally is true even with Windows 3.x and 95. However, Windows does some clever things with programs and memory so things loaded after Windows are much less restricted, especially with Windows 95. That having been said with Windows 3.x, and in some cases Windows 95, it is necessary to load things during start up. For example CD Rom drivers, sound card drivers and so on. When this happens conventional memory is used up and this can cause problems, even with Windows 95.

So how can we configure conventional memory to prevent these problems?

Well, I mentioned earlier that the Upper Memory Area has a lot of unused space in it. At one time it was not possible to directly make use of this area, but then various programs were written to allow you access. QEMM is probably the most famous program of this type. Then with Dos 5 Microsoft provided the tools necessary to access the Upper Memory Area. Basically Dos 5 introduced two new commands, DeviceHigh and LoadHigh.

The first of these, DeviceHigh, allows you to put device drivers such as you keyboard driver in the upper memory. To put it another way, if you load it in Config.Sys then DeviceHigh will load it in upper memory.

The LoadHigh command is a Dos command which can be used to load TSR's in upper memory. [A TSR in case you don't know is a Terminate and Stay Resident program, ie one which sits in memory waiting for you to do something. An example is the DosKey program.] That is anything you load in Autoexec.Bat can be loaded into the upper memory area by using LoadHigh.

In order for these two commands to work it is necessary to first load two device drivers, HiMem.Sys and EMM386.Exe and tell Dos that the upper memory area is available.

HiMem.Sys allows Dos access to extended memory, while EMM386.Exe configures some or all of this extended memory as expanded memory. It also provides access to the upper memory area.

The command to tell Dos that the upper memory area is available is Dos=UMB. Incidentally Dos itself, or at least part of it can be placed in the upper memory area with the command Dos=High.

So then all that is required to get more convention memory is load HiMem.Sys and EMM386.Exe, add the Dos=High,UMB command, change all the Device= commands to DeviceHigh= command and use LoadHigh for everything in Autoexec.Bat?

Well - not quite. That will certainly give you more conventional memory, but may not give you the maximum possible. Also some programs will not work very well in the upper memory area. Finding out which programs will not work very well in the upper memory area is, I'm sorry to say a matter of trial and error. Getting the maximum amount of conventional memory on the other hand is reasonably easy.

The first thing to do is take a copy of both your Config.Sys and Autoexec.Bat files. Then enter the command Mem. This will give you some information on how your memory is used and will look something like the following:-

Memory Type      Total = Used + Free
---------------- ------ ------ ------
Conventional      640K   195K   445K
Upper               0K     0K     0K
Adapter RAM/ROM   384K   384K     0K
Extended (XMS)  15360K  2703K 12657K
---------------- ------ ------ ------
Total memory    16384K  3282K 13102K

Total under 1 MB  640K   195K   445K

Largest executable program size   445K (455296 bytes)
Largest free upper memory block     0K (0 bytes)
The high memory area is available.

The important line here is third from the end, which gives the size of the largest program which you can run. As you can see in this case the largest program is only 445 Kb - not very large.

So how can we improve things?

Well the first thing is to look at the Config.Sys and Autoexec.Bat files. The ones used to give the above result are shown below.

Config.Sys
Device=c:\Dos\HiMem.Sys
Device=c:\Dos\Emm386.Exe NoEMS x=ce00-ceff

Device =c:\Dev\Hit-Ide.Sys /D:MSCD020 /N:1
Device =c:\proaudio\mvsound.sys d:5 q:10 s:1,220,1,5 m:0 j:0
Device =c:\Mouse\Mouse.Sys
Device =c:\Dos\ANSI.Sys

Shell=c:\Dos\Command.Com c:\Dos\ /e:1024 /p
Country=44,,C:\Dos\Country.Sys

Stacks=9,256
Buffers=15,0
Files=60
FCBS=4,0

Autoexec.Bat
@Echo Off
Rem *****************************************************
Rem * Autoexec.Bat *
Rem * ~~~~~~~~~~~~ *
Rem * Batch file to set up initial configuration. *
Rem *****************************************************

C:\AntiV\Solomon\Guard

Set Comspec=c:\Dos\Command.Com
PATH C:\DOS;C:\Windows;c:\;c:\Bat;c:\Bin;c:\scsi;c:\proaudio
Prompt $P$G
set blaster=A220 D1 I5 T3

C:\DOS\MSCDEX.EXE /D:MSCD020 /M:8
C:\Dos\SmartDrv.Exe /X

C:\DOS\KeyB.Com UK,,c:\Dos\KeyBoard.Sys /Id:166
C:\DOS\DosKey

DosKey Dir=Hdir $* /2
DosKey Win=Do Win $*
DosKey VDU=Mode Con Lines=50

Set TEMP=C:\Windows\Temp
Set WSWWORK=C:\Temp

Echo On

Since the Config.Sys file loads before the Autoexec.Bat file we must look at it first. The first two lines start up the two device drivers I mention earlier. These are necessary if we are going to make use of the Upper memory area. The Emm386 driver is shown with two parameters which are used to modify the command. These are:-

NoEMS        Which simply says that we do not want any memory configured as EMS ie we want all XMS
x=ce00-ceff    This is telling the Emm386 driver that it is not to use the memory area between ce00 and ceff in hexadecimal which is about the 820 Kb area even though it looks as though it is available. Don't worry about why I have excluded this area, it's not important at this stage.

Since we have loaded these two drivers we can let Dos know that the Upper Memory area is available and ask it to make use of it. We do this by adding the following line:-

Dos=High,UMB

The word High is telling Dos to load part of itself in the Upper Memory area. The UMB says make the Upper Memory Blocks [areas of memory in the Upper memory area] available.

Just adding the above line gives an improvement in the amount of conventional memory available. The Mem command now gives:-

Memory Type      Total = Used + Free
---------------- ------ ------ ------
Conventional      640K   118K   522K
Upper             151K    28K   123K
Adapter RAM/ROM   384K   384K     0K
Extended (XMS)  15209K  2552K 12657K
---------------- ------ ------ ------
Total memory    16384K  3082K 13302K

Total under 1 MB  791K   146K   645K

Largest executable program size     522K (534112 bytes)
Largest free upper memory block     104K (106336 bytes)
The high memory area is available.

The largest possible program is now 522 Kb, and increase of 77 Kb. Mind you part of this increase is because SmartDrive is clever enough to notice that the Upper Memory Area is available and make use of it.

But we can do better.

Look at lines 3 to 6 in the above example. These load the CD Rom driver, the sound card driver, the mouse driver and ANSI.Sys which is used for some fancy displays and prompts I like to use. All of these are being loaded into conventional memory, but there is no reason why they couldn't be loading into the upper memory blocks. To do this just replace the Device= with DeviceHigh=.

After doing this the Mem command gives the following:-

Memory Type      Total = Used + Free
---------------- ------ ------ ------
Conventional      640K    76K   564K
Upper             151K    70K    81K
Adapter RAM/ROM   384K   384K     0K
Extended (XMS)  15209K  2552K 12657K
---------------- ------ ------ ------
Total memory    16384K  3082K 13302K

Total under 1 MB  791K   146K   645K

Largest executable program size   564K (577216 bytes)
Largest free upper memory block    62K (63216 bytes)
MS-DOS is resident in the high memory area.

A gain of another 42 Kb.

Now lets look at the Autoexec.Bat file, specifically the following lines:-

C:\AntiV\Solomon\Guard

C:\DOS\MSCDEX.EXE /D:MSCD020 /M:8
C:\Dos\SmartDrv.Exe /X

C:\DOS\KeyB.Com UK,,c:\Dos\KeyBoard.Sys /Id:166
C:\DOS\DosKey

These lines load an Anti-Virus program, the Microsoft CD Rom extensions, SmartDrive, the Keyboard driver for the UK keyboard and a handy little Dos program called DosKey. All of these programs can also be loaded into Upper Memory by using the LoadHigh command, Just put LoadHigh at the start of the line. For example:-

LoadHigh c:\AntiV\Solomon\Guard

Doing that gives the following:-

Memory Type      Total = Used + Free
---------------- ------ ------ ------
Conventional      640K    25K   615K
Upper             151K   121K    30K
Adapter RAM/ROM   384K   384K     0K
Extended (XMS)  15209K  2552K 12657K
---------------- ------ ------ ------
Total memory    16384K  3082K 13302K

Total under 1 MB  791K   146K   645K

Largest executable program size     615K (629760 bytes)
Largest free upper memory block      15K (15104 bytes)
MS-DOS is resident in the high memory area.

We now have 615 Kb available - a massive increase of 170 Kb over the original 445 Kb.

Now I must confess that while the above is a real example, it is in fact my own standard set-up, it is also an easy one to deal with. The reason is that all the programs fit into upper memory. In some cases you may well find that you do not have enough space in the Upper Memory Area to fit all your programs. In that situation the only thing you can do is try and arrange it so that you get the maximum possible in the Upper Memory area. And, unfortunately, the only real way of doing that is trial and error.

There are a couple of things which can help. The first of these is the mem command with the parameter /p. This will give you a much more detailed description of just what is in memory. For example:-

Modules using memory below 1 MB:

  Name         Total     =   Conventional +  Upper Memory
-------- ---------------- ---------------- ----------------
 MSDOS     17,341   (17K)   17,341   (17K)        0   (0K)
 HIMEM      1,120    (1K)    1,120    (1K)        0   (0K)
 EMM386     4,144    (4K)    4,144    (4K)        0   (0K)
 COMMAND    3,696    (4K)    3,696    (4K)        0   (0K)
 KEYB       6,944    (7K)        0    (0K)    6,944   (7K)
 DOSKEY     4,144    (4K)        0    (0K)    4,144   (4K)
 MOUSE     12,080   (12K)        0    (0K)   12,080  (12K)
 ANSI       4,256    (4K)        0    (0K)    4,256   (4K)
 SMARTDRV  29,024   (28K)        0    (0K)   29,024  (28K)
 Free     702,240  (686K)  628,864  (614K)   73,376  (72K)

Memory Summary:

 Type of Memory    Total    =   Used  +  Free
---------------- ---------- ---------- ----------
 Conventional      655,360     26,496    628,864
 Upper             129,824     56,448     73,376
 Reserved          393,216    393,216          0
 Extended (XMS)  7,210,208  2,323,680  4,886,528
---------------- ---------- ---------- ----------
 Total memory    8,388,608  2,799,840  5,588,768

 Total under 1 MB  785,184     82,944    702,240

 Largest executable program size    628,768 (614K)
 Largest free upper memory block     40,784 (40K)
 MS-DOS is resident in the high memory area.

The important thing here is the first block titled, Modules using memory below 1 MB: which lists all the programs. The first column shows how big the program is. Since we now know the size of all the programs and the size of the Upper Memory, from the second block - Memory Summary:, it is possible to work out which programs will best fit.

The second thing which can help get the most into the Upper Memory area is to put the largest in first. Programs often need more memory to install them selves than they need to run. Thus putting the smallest in last can often mean you will get more in.