Search code examples
multithreadingdelphiblocking

Where is my program waiting?


I have a Delphi 10 multithreading application with blocking calls. When I exit it is sometimes not unloaded from RAM and Delphi debugger isn't stopped.

How (tool, method) to detect in which routine is my app waiting?


Solution

    1. Hit the Pause button (Run, Program Pause)
    2. Show the Threads window (View, Debug Windows, Threads or Ctrl+Alt+V)
    3. Double-click on each thread in turn and inspect the call stack (View, Debug Windows, Call Stack or Ctrl+Alt+S)
    4. Look for your routines in the call stack and evaluate the evidence you see before you when perusing the code at the top of the call stack, but in your source files

    Sometimes it is more informative to run the above steps with Debug DCUs enabled (Project, Options..., Delphi Compiler, Compiling, Use debug .dcus), and runtime packages disabled (Project, Options..., Packages, Runtime Packages, Link with runtime packages)