Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6856521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:53:49+00:00 2026-05-27T01:53:49+00:00

I’m involved in various C++ projects (mostly using MSVC6 up to MSVC10) in which

  • 0

I’m involved in various C++ projects (mostly using MSVC6 up to MSVC10) in which we recently found a few handle leaks (thread handles as given by the CreateThread function). I suspect that there are plenty of other handles being leaked as well and I’d like to integrate a test which verifies that no handles are leaked into our nightly test results.

My idea was to develop a DLL which instruments the relevant kernel32.dll functions (CreateThread, OpenProcess, CreateProcess and a dozen more) as well as the CloseHandle function. The DLL would then, for each handle being acquired, memorize a backtrace. At the end of the process, the DLL would print all backtraces of handles which weren’t closed to some sort of log file, which could then be parsed by the test framework.

This will of course also yield backtraces for all handles which are still reachable (so technically, they didn’t leak – maybe the author intended that the OS reclaims them when the process terminates) but I Guess explicitely closing them doesn’t hurt – especially since we already have some nice RAII wrappers for this stuff, we just don’t use it as much as we should.

Now I’m wondering – this seems like a fairly straightforward approach; maybe somebody here is alware of a library which already does this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:53:49+00:00Added an answer on May 27, 2026 at 1:53 am

    This is definitely possible, but I don’t think there’s a library that does it yet.

    The easiest way, I think, would be with Application Verifier. You can get it from Microsoft’s Debugging Tools for Windows. Configure it to track your application’s handles, run your application in a debugger for a bit, and then a list of handles will be dumped when your application exits.

    Another way to do it, without Application Debugger, would be to set a breakpoint or pause before your application exits. While the application is paused, use something like Process Explorer to obtain a list of all open handles.

    For your purposes, I think the latter would be the better choice. I’m not sure of any automated tools that use the debug output. You can use some functionality of the WDK to retrieve a list of the current process (or another process’s) open handles, but it is a bit complicated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.