Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a handle leak detector which can be linked into an existing application?
    primarykey
    data
    text
    <p>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 <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms682453(v=vs.85).aspx" rel="noreferrer"><code>CreateThread</code></a> 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.</p> <p>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 <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms724211(v=vs.85).aspx" rel="noreferrer"><code>CloseHandle</code></a> 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.</p> <p>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 <a href="http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization" rel="noreferrer">RAII</a> wrappers for this stuff, we just don't use it as much as we should.</p> <p>Now I'm wondering - this seems like a fairly straightforward approach; maybe somebody here is alware of a library which already does this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload