StackSpace
StackSpace Obtain amount of unused space in the stack
#include <Memory.h> Memory Manager
long StackSpace( );
returns amount of unused space in stack (at time of call)
StackSpace checks how close your application is to peril. It can also be used
before creating a heap zone in the stack (to squeeze a few extra bytes out of the
system). The return value is transient - the stack can grow a lot very
quickly.
Returns: a long integer; the amount of space between the base of the stack and
the current value of the stack pointer.

Notes: One trick for getting some additional memory is to carve a zone out of the
bottom of the stack (at a place where the stack is not being used). The
default stack is about 8K, and it is best to leave at least 4K to 6K there. So
at most you can create about a 2K heap zone. Of course you should use
StackSpace beforehand, to check if this is a feasible approach.
One instance where you might need a temporary zone is in a routine to
handle a serious memory-full crunch. For instance, creating an alert or
dialog window takes some heap space. See InitZone for details of creating a
zone.
The global variables CurStackBase (at 0x0908) and MemTop (at 0x0108)
may be of some help.