At 10:10 AM 8/17/2003, Richard Coutts wrote:
I'm using some recursive calls that are filling up my stack.  There's no
easy way around the recursion, so I'm finding other ways to be frugal with
stack usage.  I've been reading up on the stack issues and have a couple of
questions:

(1) I read somewhere that even if I keep below the stack size that I allot
myself, that Palm Hacks can occupy some of the stack, and that my app
consequently may not have as much as it thinks it does.  E.g., if my app is
compiled for a 4K stack, but there are Hacks that occupy 512 Bytes, that I'm
really working with a 3.5K stack (is this true?  I'm not very savvy about
how Hacks work).  If this is the case, how do you work with this?  Do you
allocate the stack to be a little bigger than it needs to be to allow of
Hacks to take some of it?

Hacks don't take up permanent stack space -- when they're invoked, they can use stack on top of your application, but that should be all cleaned up when they return. The same applies to sub-launched programs, like ones that receive notifications.


(2) When the stack overflows, I get the initial message from POSE listing
the last 6 or so functions on the stack with the amount of stack they're
using in parenthasis.  But, there's usu. a dozen or so function calls above
that that are the real culprits -- is "#pragma warn_stack_usage 1" the only
way to get a function's stack size, or is there a way to see the amount of
stack all of the functions were using at the time POSE crashed?

If you look at each function, there usually is an instruction that looks like "link a6,#N". The N value is the amount of stack space reserved for local variables. More stack can still be used as storage for function arguments, but that will give you a guide to where things are going wrong.


--
Ben Combee <[EMAIL PROTECTED]>
CodeWarrior for Palm OS technical lead
Palm OS programming help @ www.palmoswerks.com



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

Reply via email to