Windows – Closing Process of a Delphi App under Vista

delphiwindows-vista

When we created our program, it closed properly under XP, but under Vista, even though the program is closed, the process is often still running until I open task manager and manually kill the process.

Any suggestions on how to make sure this is closed when we close the program? What a pain.

Mark Gundy
www.magchat.com

Best Answer

The debugger will be your friend here. Step through the shutdown until you get stuck. That'll be the best bet.

But... assuming for some reason the debugger is affecting the behaviour, or can't be used for some other reason:

  • A few earlier replies suggest using FastMM. This has been the default memory manager for delphi since D2006. You can try flipping on the options to report memory leaks... but that'll only work after you've finished shutting down the process, which is what isn't working. :) So I doubt it will help you much in this case. The full version of FastMM, as opposed to the standard one packaged with delphi, might have some other helpful features... But I can't recall any that would help here.

  • To inspect your app while it's stuck, you could try the sysinternals tools, like Process Explorer & Process Monitor. Process Monitor may show you if it's choking on any ACCESS_DENIED errors, etc, and the stack trace at the time of the error. Process Explorer could be especially useful, by listing all the handles your process is still holding open, and allowing you to view the stack of all its living threads. A familiar function or two, in the stack traces of any hung threads, may send you hunting in the right area.