> If the new allocation fails, it ErrDisplayIf's a message.

You're treating allocation failures as a system error rather than a user
error. This is appropriate if you're pre-flighting, but, as I said,
pre-flighting isn't recommended. For your pallet example, the concern is
that a hack may be allocating memory whenever you call a systrap. Since
you're calling Data Manager functions within your loop, there is plenty of
opportunity for hacks to act. If you can rule out hacks on your users'
devices, then pre-flighting should work for your palette example.

> UInt16 uDynamicMemRequired4OnePallet = uPallets2Xfer*PALLETDYNHEAPREQ;
> UInt16 uStorageMemRequired4OnePallet =
uPallets2Xfer*PALLETSTORAGEHEAPREQD;
>...<snip>...
> I need to figure out what PALLETDYNHEAPREQ & PALLETSTORAGEHEAPREQD should
be
> defined as.

You can figure out the space required in both heaps by analyzing the
individual actions you perform. Remember that memory isn't generally
contiguous, so you should be looking at the largest available chunk and not
the total free space. If the largest available chunk isn't big enough, the
operation may still succeed, but you can't know. You can compact the heap
and check if that helps, but if it doesn't, you'll have to disallow the
operation even though it might actually be possible. Resizing a chunk larger
is equivalent, for your purposes, to allocating a new chunk. You'll have to
allow for the Memory Manager's overhead, which is something that
applications aren't privy too.

> Also wanted to use this type of logic at the beginning of PilotMain, to
test
> for enough application framework memory overhead just to get the
application
> to our mainmenu.

Because you call SysHandleEvent in your event loop, there is plenty of
opportunity for other applications on the device to consume memory. The OS
can also consume memory when an event is processed. Pre-flighting can't be
used safely in this situation.

I'd try to come up with an alternative to pre-flighting. For example, maybe
you could do your database operation using categories to mark the changes as
tentative. If you succeed, then you just recategorize the records to
finalize the transaction. If you fail, then you just delete the tentative
records.
--
Danny @ Palm

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to