Using the Stack

The stack is the storage area for variables that are referenced in a function. Windows CE allocates memory for a variable from the stack and deallocates the memory after the function call is complete. When a thread or process begins, Windows CE allocates one page of memory to the stack for that thread. Each thread has a stack, and each stack contains up to 60 KB of data: Windows CE reserves 58 KB for the stack, and reserves the final 2 KB for stack overflow control.

Note Exceeding the 60-KB limit for a stack causes a system-access violation that shuts down your application.

By default, you call on the stack each time that you declare a variable. You can also allocate memory from the stack by using the HeapAlloc function.