The size of the stack that is defined for each task created is critical, but it can be difficult to get this exactly right. If the size of the stack is too low, then the task will blow through its limit as it traverses through a number of nested calls or if too many local variables are declared. If that happens, it will overwrite areas of memory that it is not supposed to, which in term can cause all sorts of strange and catastrophic behavior. If the stack is declared too large, it is a waste of critical and expensive memory. Determining the proper size of a stack is not always a deterministic process, since the way in which the task uses it can be quite complex. Often a developer will need to run the application for an extended period of time and use a tool to measure stack usage. SYS/BIOS provides a Code Composer Studio tool called the Runtime Object Viewer (among other things) can monitor all the declared stacks. The Task module also defines an API called Task_stat that does the same thing. Both of these methods take advantage of the fact that BIOS initializes the stack with a bit pattern that allows tools to later check how much stack has been actually used. The Task module also defines checkStackFlag. This is enabled by default and when it is enabled, every time the task runs, it will check that the stack pointer is within the bounds of the defined stack range. This can also be disabled to optimize task switch times.