Palm Mem Management

yakconspiracyΛογισμικό & κατασκευή λογ/κού

14 Δεκ 2013 (πριν από 7 χρόνια και 8 μήνες)

438 εμφανίσεις

Palm memory management

Although newer Palms are getting more and more RAM most still have under 16MB
and none of them have ha
rd drives. All applications and databases are stored in the
RAM so Palms have to do things a little differently than PCs. We wouldn't want our
applications overwriting permanent storage now would we.

The RAM is divided into two sections: the storage area
and the dynamic area (or
dynamic heap). As you can guess, the storage area is where permanent data resides,
like applications and databases, and is handled by the
Database Manager
. The
dynamic heap is used for Palm OS globals, Palm OS dynamic allocations, your
application's global variables, your application's stack space, and any dynamic
allocations your application makes. The dynamic heap is handled by t

and its size depends on the amount of RAM your Palm has, the OS version
and the applications you have installed.

Because of the limited amount
of dynamic memory, the Palm OS needs to be able to
move chunks of memory around to keep its free space contiguous so there is enough
room for new allocation. Thus there are two types of memory chunks,

. Pointers are nonmovable chunks of

memory, whereas handles are movable
by the Palm OS. It is recommended that you use handles as much as possible.

The Memory Manager API

In order to manipulate memory on the Palm, you must use the
Memory Manager

Palm memory

The Palm OS system software i
s designed around a 32
bit architecture. The system uses 32
bit addresses, and its basic data types
are 8, 16, and 32 bits long.

The Palm OS divides the total available RAM store into two logical areas:
dynamic RAM

storage RAM
. Dynamic RAM is used
working space for temporary allocations, and is analogous to the RAM installed in a typical desktop system. The remainder of
the available RAM on the card is designated as storage RAM and is analogous to disk storage on a typical desktop system.

Because p
ower is always applied to the memory system, both areas of RAM preserve their contents when the handheld is turned
"off" (i.e ., is in low
power sleep mode). See
"Palm OS Power Modes"

in the chapter
"Palm System Support"

in this book. All of
storage memory is preserved even when the handheld is reset explicitly. As part
of the boot sequence, the system software
reinitializes the dynamic area, and leaves the storage area intact.

The entire dynamic area of RAM is used to implement a single heap that provides memory for dynamic allocations. From this
dynamic heap
, the syste
m provides memory for dynamic data such as global variables, system dynamic allocations (TCP/IP,
IrDA, and so on, as applicable), application stacks, temporary memory allocations, and application dynamic allocations (such
those performed when the applic
ation calls the


The entire amount of RAM reserved for the dynamic heap is always dedicated to this use, regardless of whether it is actual
ly used
for allocations. The size of the dynamic area of RAM on a particular handheld varies according to the OS version running, the

amount of physical RAM available, and the requirements of pre
installed software such as the TCP/IP stack or IrDA stack.
Table 5.1

provides more information about the dynamic heap space that currently available combinations of OS and hardware provide.

Traditional file system uses a buffer
to store information before it can be read/write into

Palm does not have a

buffer and only needs to be able to store information into memory.

In order to store data, it first splits up the data into records which it then stores these
records into

a database system that has been setup scattered through out memory.

Traditional file systems will store data in a contiguous chunk.

Databases contain related data. Databases can be spread out over multiple Ram

To find data it goes to the D
ata Manager searches for it in an index which will tell where
the database is located in memory then goes directly to the memory and retrieves the

Each record entry stored in a record list has three fields and is 8 bytes in length.
Each entry has th
e local ID of the record which takes up 4 bytes: 1 byte of attributes and
a 3
byte unique ID for the record. The

field, shown in
re 6.1
, is 8 bits
long and contains 4 flags and a 4
bit category number. The category number is used to
place records into user
defined categories like "business" or "personal."

Each record has the following attributes.


bit is set in the

flags, but its entry in the database
header remains until the next synchronization with the PC.


bit is set whenever a record is updated.


bit is set when an application currently has a re
cord locked for
reading or writing.


bit is set for records that should not be displayed before the user
password has been entered on the handheld.

Records can be resized.

When you ‘delete’ a record the local ID stored in the record entry
is set to 0 and is still on
the palm docking with a computer is required to delete the record or data from the palm.

Data manager can









sets busy bit to confirm its being used ,


lets you look at the record but not change it, doesn’t set the busy bit.,






The Resource Manager

Applications can use the Resource Manager much like the Data Manager to retrieve and
save chunks of data conveni
ently. The Resource Manager has the added capability of
tagging each chunk of data with a unique resource type and resource ID. These tagged
data chunks, called
, are stored in resource databases. Resource databases are
almost identical in structu
re to normal databases except for a slight amount of increased
storage overhead per resource record (two extra bytes). In fact, the Resource Manager is
nothing more than a subset of routines in the Data Manager that are broken out here for
conceptual reaso
ns only.