Due to various perceived problems with earlier versions of PalmOS, including 1.0 and 2.0, I use two strategies to prevent memory conditions from getting too low in an application which may need to allocate an indefinite and unbounded amount (as well as the required checking for NULL pointers on all allocation calls.)
The application inquires as to the amount of free memory at startup, and sets a watermark slightly below this (by 1k to 16k, depending on the OS version). However, since other tasks, hacks and OS calls can also allocate memory underneath the application, the app also allocates a "Rainy Day" fund, a memory block used only for temporary calculations and never across OS calls, and which can be free'd before responding to any menu events or calling any dialogs if free memory goes below what the watermark should leave behind. If there isn't enough memory available to reallocate the rainy day fund afterwards, there might be enough memory left to display a warning or exit dialog before bailing out. I haven't checked to find out whether these strategies are required on current versions of PalmOS, so perhaps this application is now suboptimal in using all available dynamic memory. Ron Nicholson HotPaw Productions <http://www.hotpaw.com/rhn/palm/ > -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
