Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trace handle leaks?

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!

like image 493
jpfollenius Avatar asked Oct 21 '11 07:10

jpfollenius


1 Answers

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!

like image 80
PeterK Avatar answered Oct 06 '22 03:10

PeterK