I am having a problem with stack overflow that is corrupting some
global data and sometimes causes a Fatal Exception.  I need some help
understanding the dynamic heap and it's usage.

I would like to read a detailed description of the stack and dynamic
heap issues but the docs don't have enough information; or maybe I'm
just dense:-)

I have an application that uses a limited amount of recursion.  I had
placed limits on this and the current version of the app works
fine.  But I made a couple of changes and now I get the error.  I made
two changes: 

  1) I increased the size (approx 200 bytes) of a small array in one 
     of the functions that is recursed.  This is probably the source
     of my problem, if the local array uses dynamic heap, which I 
     suspect does.

  2) I added an additional global array that is approximately 250 bytes
     in size.  This is the array that gets corrupted by problem in
     (1).  So, these two are related some how.

It is my understanding that the dynamic heap is limited to something
like 12-14K.  Is that true?  Is this where global variables reside?

It is also my understanding that the stack space is something like
4K.  Is that true?  Do local variables in subroutines reside in the
stack or the dynamic heap?

If there is a stack overflow, does the stack just expand into the global
variable space?  Is there any way to test for this prior to it
happening?

Now, assume (1) is the source of my problem.  The array is approx 200
bytes in size.  Now, if I recursively call this function 3 times that is
approximately 600 (just for the array).  Is that 600 bytes part of the
stack or dynamic heap or what?

If I created a global array that was 600 bytes and removed the 200 byte
array from the function, would that relieve the problem or am I in the
same fix?

If instead of the global array, I used the memory manager to allocate
600 bytes for the array, would that help?  

Is memory that is allocated by the MemManager part of the dynamic heap?

Assuming that someone understands my problem, is there a way around this
without having to eliminate the recursive calls?

Is there any place where I can get a detailed description of the
interaction of the stack with the dynamic heap and/or other memory.

Thanks

Mike






-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to