### Check Heap When Stopping

Select Run->Check heap when stopping to check all memory blocks allocated or freed by the runtime memory management functions. This makes sure that overwriting has not occurred outside the bounds of allocated blocks, and that free memory blocks have not been overwritten.

If Check heap when stopping is enabled, the heap is checked each time the program stops. For example, the heap check is performed at each breakpoint or after each step command. If a heap error is detected, your application terminates. The Termination dialog displays showing the source line number where the application stopped and the heap check was performed.

Notes on Check Heap when Stopping

- For the Check heap when stopping choice to work, you have to compile your application using the IBM C and C++ compiler option.
- If you enable the Check heap when stopping choice and run your application to termination, and the application contains a heap error, the heap check is not made. To check the heap just before termination, set a breakpoint on the last line of your application.
- (OS/2 only): If you are debugging a multiple thread program and a thread stops while running in compiler memory management code that is holding a memory semaphore, the heap check will not be performed.
- (OS/2 only): If the stopping thread is running in 16-bit code, the heap check will not be performed.

Debug Heap Use