DOS, THE PALMTOP, MEMORY, AND STORAGE
Andreas Garzotto, 09-Sep-1999
"Not enough memory", "PalMemFail" and other error messages often lead to
confusion about "what memory?". The intention of this text is to shed some
light onto those topics so that you can understand what all those memory
issues are about and find solutions to memory problems.
The Palmtop memory
In the Setup application of the palmtop, you can adjust the amount of memory
that should be given to the "system" and the amount that should be given
to the "disk". There is a certain amount of memory installed on your palmtop,
typically 1, 2, 4, 8, 32, 64, or 96 megabytes. Almost all of it can be
used as storage, i.e. to save files. As you soon find out in the Setup
application: no matter how many megs of memory you have installed, you
can only use about 640k for the "system" and all the rest can only be used
as storage. "system" means that the processor can directly work with that
memory and operate on it. Storage means that the processor cannot directly
access that memory, but only load chunks of it (typically pieces of 512
bytes) into the system memory to process it further. So most of the installed
memory cannot really be used as system memory, but only to simulate disk
storage.
DOS and the 80186 processor
Why this limitation of 640k of system memory? The most limiting factor
is the built-in 80186 processor. It has only 20 address lines, i.e. 20
wires can go out of the processor and select an address in a memory chip.
This means, the processor can distinguish between 2^20 memory addresses,
which is a little more than a million. Thus, the processor cannot address
more than 1 megabyte of memory. Due to the design of DOS, this range is
limited even further. DOS specifies that the memory used for storing what
should be displayed on the screen starts at memory location 655360 and
the BIOS, i.e. the ROM, must be at a specific address above that. This
leaves a memory block of only 640k to be used for the operating system
and the programs.
Programs and the 80186 processor
On "normal" DOS computers, DOS itself eats away quite a bit of the 640k
for its own purposes. On the palmtop, this is a bit better because a large
portion of the DOS code is in ROM. So on the palmtop you can get a piece
of memory for the programs that is around 590k. If System Manager is loaded,
this memory shrinks by about another 130k so that even less memory is available
to the programs, maybe around 460k. Next, there are so called TSRs, programs
that, once launched, Terminate and Stay Resident in memory. By doing that,
they are always available, most often by using a special key combination.
Typical TSRs are Buddy or LXCIC. They are very useful, but they reduce
the amount of memory even further. In a "normal" installation, i.e. with
a few essential TSRs loaded, there are about 550k of memory left outside
of System Manager and about 420k within System Manager. This is the complete
amount of memory available to the programs you run.
Today's programs often come close to that size. Many programs even need
more than is left when System Manager is still running, so that you need
to terminate System Manager in order to be able to run them at all.
But this is not the end of the story. There are further limitations.
For some unknown reason, when Intel created the 8088 processor, they copied
all the bad features from the DEC PDP/11 processor and omitted all the
good ones. The consequence is that the processor can only see a window
of 64k at once. This is still the same with the 8086 and the 80186 processors.
Thus the actual data space a program can reasonably work with, is only
64k. Whenever more memory is needed, this can only be done using programming
tricks or by moving the window around before each memory access. The latter
is called "large memory model". It is supported by many compilers. The
problem is that it creates programs that run slower and are much larger
- which again means that they will eat away a lot of the about 500k that
is available to programs and make it impossible to run several programs
at once (e.g. a TCP/IP stack and an email client and an editor that edits
a message from the email client - they all have to be in memory at once).
Because of the disadvantages of the large memory models, most available
DOS programs are limited to a data space of 64k. This means that *all*
data, including any text the program shows, any data you enter, any data
the program needs in memory in order to work, needs to be placed within
64k. Most of the time when you see error messages such as "Out of memory"
or "PalMemFail", this is because the program has no more memory available
WITHIN THOSE 64K.
Often, there is not a lot you can do about that. For PAL programs, the
most promising approach is to have a look at the CFG file for that program.
The whole CFG file needs to be loaded into memory and thus eats away a
big junk of the 64k. If you remove comment lines (lines starting with a
semicolon) and other unneeded stuff, this most probably helps.
SC and MaxDOS
Software Carousel and MaxDOS are two really wonderful programs. Both of
them help you to get as much of the 640k of memory as possible. They do
that by swapping the memory out to the disk, i.e. they write whatever is
in the portion of the 640k that is used for your programs to the disk,
thus freeing that memory for other programs, and read it in again when
it is used again. By doing that, you can have several programs open at
the same time that would not fit into the 640k at once. When using MaxDOS,
you can even start a new program from within another program (e.g. PGP
from within an editor from within a mailer) if there would otherwise be
not enough memory to run that program.
However, both SC and MaxDOS do not help if there is a problem with the
64k available as data space to each program.
EMM
Expanded memory is another very useful device to "increase the memory"
in certain situations. It makes use of the fact that 16k of memory between
the memory reserved for the display and the memory reserved for the ROM
are unused. EMM makes these 16k available to programs and provides a means
to swap 16k pieces of other memory (e.g. from a disk file) in and out of
those 16k fast.
EMM can only be used by programs that are explicitly designed to use
it. Such a program has its normal 64k plus another 16k of EMM memory that
it can access. Programs that work with bigger chunks of data that do not
need to be accessed at the same time, can make effective use of EMM, e.g.
word processors that swap the piece of text that you are currently working
on into the 16k window while the rest of the document is elsewhere.
SUMMARY
There are three kinds of "memories":
1) memory used as storage. You have as much of it as you provide
in terms of memory cards, flash cards or memory upgrades.
2) memory available for DOS. There is a maximum of 640k. All programs
running at the same time (including DOS and/or System Manager) must
fit into those 640k so that you can use them.
3) internal program memory. These are typically 64k. A program
must fit all its data it cannot store on a file into those 64k. If
it cannot do that, you get out of memory errors such as "PALMemFail".
If you cannot save a file to disk because of a "out of space" message,
it is the type 1) memory that is not sufficient. If you cannot launch a
program and DOS reports "not enough memory", it is the type 2) memory that
is not sufficient. If a program tells you "out of memory" or "PALMemFail",
it is the type 3) memory that is not sufficient.