<[EMAIL PROTECTED]> wrote
> I got the error message from the Emulator "The application has just
overflowed
> the stack" when trying to kill the debug. The Reset from the message box
would
> not get me out. I am wondering what had caused the problem. In my
application
> the code size is about 16K and data size is about 10k. Thanks in advance.
>
Aah, the joy of learning :-) Or, to put it another way, the painful
detail involved in programming :-(
The code and data size of your program are it's profile before it does
anything. Once it begins to call functions the stack is used to pass
parameters into functions and grows as those functions call more functions
(I'm not sure how much of this you already know so I'll quit the lecture
here - someone else might be able to point us to a good introduction to
these concepts). The code and data size really have little connection to
how much stack space a program uses (although it's difficult to reduce stack
usage without increasing heap usage).
Anyway, the problem is that the stack is limited and while under PC
operating systems 'limited' means 64K to a megabyte, under PalmOS it means
2K to 4K (I think, anyone more educated able to correct me?)
So if you call a function and pass two integers and the text "something of a
problem" you've increased the stack by about (2 + 2 + 22 + some overhead).
On the other hand if you pass two integers and a *pointer* to the text
"something of a problem" you're increasing the stack by (2 + 2 + 4 + some
overhead - pointers are generally longs). This is fairly rough, but do you
get the idea?
So what you're looking for in your code is places where you're passing more
than you have to as arguments on the stack. Alternatively you might be
calling a function that calls a function that calls the first function in an
uncontrolled loop until they blow out the top of the stack. In controlled
circumstances this is called recursion and should generally be avoided on
the Palm. In uncontrolled circumstances it's called a bug and should always
be avoided :-)
Anyway, I hope this hasn't confused you more than it's helped. Feel free to
email me if you can't sort it out.
Chris Tutty
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/