Question

In one of my applications I observe an increasing number of handles. The number is incremented roughly every second without using the application, so there must be a handle leak in some part of the background processing code.

How can I trace such leaks? Are there any tools to help with this? What are the patterns to look for when tracing handle leaks? What are the most common mistakes that cause a handle leak?

A bunch of questions, but I hope they are related enough to put them in one question. Thanks for any input in advance!

Was it helpful?

Solution

I suggest using Process Explorer. Run it as Administrator to make sure you see all the relevant data. There you can observe what kind of handles your process has and which are excessively being created and not free'd. This should help you to narrow down the search (in my case, i had sockets leaking all over the place due to some false assumptions about the behaviour of winsocks.). Perhaps then you can isolate the relevant code and post it here for us to check if there is anything wrong. Good luck!

OTHER TIPS

Some profilers (i.e. AQTime) can profile Windows resource applications. If you're using XE, you have a basic version of AQTime available.

Handle leaks are common if an execution path doesn't close them properly - but a in Windows a handle is a very common item used in very many different situations, which kind of handles is your application leaking?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top