Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check HandleCounts....

Status
Not open for further replies.

Iceman2005

Programmer
May 6, 2005
22
US
Guys..... i am writing a program...and inside i am doing some heavy COM related stuff (use for parsing XML) in C++.

Seems like COM is giving me lots of Handle leaks...
i am not sure how to deal with this.

I would first like to write a simple program (without COM)
just a very simple program that will count the number of Handles currently on the running process.

Like i have a program called MyProg.... MyProg runs and will do a printf of its own handlecount to stdout.

How do i do that?

thanks,
iceman
 
what handles are you actually trying to keep track of? handles to windows? hresults? if you felt like doing it manually you could just keep a static counter and increment/decrement with each new and delete of the handles. not really sure everything youre after.
hope that helps a little.
good luck,
steve
 
if your just looking for a program to check to see if your code has leaks, have a look at ProcessExplorer from sysinternals.


if you still want to go down the writing your own program route, there is an API call

GetProcessHandleCount


that should do what you want (requires XPSP1 however).

alternatively you could try using

NtQuerySystemInformation


(i think theres also a way to do it with WMI but im not 100% sure)

If somethings hard to do, its not worth doing - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top