Stack Space

Prior to OS 3.0, the stack space was fixed at about 2.5 KB. For OS 3.0 and beyond, an application can provide a resource specifying a desired stack size. If no such resource is defined, the default stack size is 4 KB.

Keep in mind that stack space is used by all of the following:

  • Your application code directly

  • The OS, whenever you call an OS routine

  • Other applications when called by the OS (e.g., during a Find, a Beam Receive, or an Alarm)

For those launch codes where the OS provides a new stack to an application (like sysAppLaunchCmdNormalLaunch), it does so by allocating a nonrelocatable memory block, and setting up the processor’s stack pointer to the last byte of that memory block. On the processors currently used by the Palm OS, the stack grows down (as items are pushed on the stack, the stack pointer points to lower memory addresses).

In order to specify a stack size other than the default, you’ll need a `pref' resource, with ID 0. The resource consists of the following:

Priority

A 2-byte integer specifying the priority of this application. It is currently unused, but you should set it to 30.

stackSize

A 4-byte desired stack size (in bytes). The default, if you don’t provide a stack size is 0xD00 (3.25 KB) for OS 3.0 to OS 3.3, and 3.5 KB for OS 3.5 and OS 4.0.

minHeapSpace

A 4-byte minimum heap size necessary for this application to run. It is currently unused, but you should set it to 0x1000 (4 KB).

APIs

There is a single API that returns information about ...

Get Palm OS Programming, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.