<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Comment Feed for Channel 9 - Understanding handle leaks and how to use !htrace to find them</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them/RSS"></atom:link>
	<image>
		<url>http://ecn.channel9.msdn.com/o9/previewImages/100/257621_100x75.jpg</url>
		<title>Channel 9 - Understanding handle leaks and how to use !htrace to find them</title>
		<link></link>
	</image>
	<description>
Hello, my name is Jeff Dailey, I’m an Escalation
Engineer for the Global Escalation Services Platforms team.&amp;nbsp;&amp;nbsp; I’d like to show you how to debug and find leaking handles within your application or other process.&amp;nbsp; We can do this with the !htrace command in windbg .&amp;nbsp; Windbg is the
 Microsoft Windows Debugger most of us use in GES/CPR&amp;nbsp; for debugging.&amp;nbsp;&amp;nbsp;&amp;nbsp;
 
&amp;nbsp; 
Handles are a value we use in user mode, that when passed to a call that transitions to kernel, are used as an offset in your handle table to reference kernel mode objects.&amp;nbsp; Kernel mode objects are
 generally allocated from pool.&amp;nbsp;&amp;nbsp; If you are having pool consumption problems and seeing errors like
2020 or 2019’s reported there is a good chance you may have a handle leak associated with them.&amp;nbsp; This is generally
 due to not doing a CloseHandle() on the handle when you have finished using it. 
&amp;nbsp; 

The following is the sample source for a handle leak that we will be debugging in our demo video. 
&amp;nbsp; 
// leakyhandles.cpp : Defines the entry point for the console application. 
// 
&amp;nbsp; 
#include &amp;quot;stdafx.h&amp;quot; 
#include &amp;lt;windows.h&amp;gt; 
&amp;nbsp; 
&amp;nbsp; 
void fun1(void); 
void fun2(void); 
void fun3(void); 
void fun4(void); 
&amp;nbsp; 
int main(int argc, char*
argv[]) 
{ 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(1) 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fun1(); 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fun2(); 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sleep(100); 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0; 
} 
&amp;nbsp; 
void fun1(void) 
{ 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fun3(); 
} 
&amp;nbsp; 
void fun2(void) 
{ 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fun4(); 
&amp;nbsp; 
} 
void fun3(void) 
{ 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HANDLE hEvent; 
&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hEvent = CreateEvent(NULL,TRUE,TRUE,NULL); 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CloseHandle(hEvent); 
} 
void fun4(void) 
{ 
&amp;nbsp;&amp;nbsp;&amp;nbsp; HANDLE hEvent2; 
&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hEvent2 = CreateEvent(NULL,TRUE,TRUE,NULL); 
} 
&amp;nbsp; 
Thank you.
 
Jeff Dailey 
Escalation Engineer (Platforms core team) 
 
</description>
	<link></link>
	<language>en</language>
	<pubDate>Thu, 23 May 2013 15:25:44 GMT</pubDate>
	<lastBuildDate>Thu, 23 May 2013 15:25:44 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<item>
		<title>Re: Understanding handle leaks and how to use !htrace to find them</title>
		<description>
			<![CDATA[
<p>Seems like the CHM which you have shown&nbsp;comes with&nbsp;MS confidential (private) version of windbg...</p>
<p>(though there is not much difference in the page thats shown!)<br>
<br>
But thanks for taking initiative and start giving nice small tutorials on debugging with windbg..</p>
<p>posted by jigarmehtamscit</p>]]>
		</description>
		<link>http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them#c633254043610000000</link>
		<pubDate>Fri, 14 Sep 2007 22:06:01 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them#c633254043610000000</guid>
		<dc:creator>jigarmehtamscit</dc:creator>
	</item>
	<item>
		<title>Re: Understanding handle leaks and how to use !htrace to find them</title>
		<description>
			<![CDATA[For the record, the &quot;internal&quot; version is essentially used for communication between the people maintaining the CHM. It doesn't have any &quot;secrets&quot; in it -- just boring stuff like &quot;this needs to be cleaned up&quot; or &quot;can you check with Bob to see if there
 is an easier way to do this&quot;. <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-4.gif' alt='Tongue Out' /><br>
<p>posted by dcook</p>]]>
		</description>
		<link>http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them#c633254903940000000</link>
		<pubDate>Sat, 15 Sep 2007 21:59:54 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them#c633254903940000000</guid>
		<dc:creator>dcook</dc:creator>
	</item>
	<item>
		<title>Re: Understanding handle leaks and how to use !htrace to find them</title>
		<description>
			<![CDATA[Thanks Jeff!<br>
<br>
Hope to see more of those trainings in future...<br>
<br>
Cheers,<br>
Volker<br>
<br>
<a href="http://www.voneinem-windbg.blogspot.com/">http://www.voneinem-windbg.blogspot.com/</a><p>posted by vve</p>]]>
		</description>
		<link>http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them#c633256388280000000</link>
		<pubDate>Mon, 17 Sep 2007 15:13:48 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them#c633256388280000000</guid>
		<dc:creator>vve</dc:creator>
	</item>
	<item>
		<title>Re: Understanding handle leaks and how to use !htrace to find them</title>
		<description>
			<![CDATA[
<p>i have tried for several times to watch this video, but every time after it played about 1 or 2 mins, it just stopped...</p>
<p>i have no way to finish watching the video, is there anyway i can do about it?? my bandwidth is 12mb download/1mb upload, so it's not a bandwidth problem.</p>
<p>is there anyway i can download the video or just think a way to help me be able to watch it....</p>
<p>posted by MythTW</p>]]>
		</description>
		<link>http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them#c633272695620000000</link>
		<pubDate>Sat, 06 Oct 2007 12:12:42 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them#c633272695620000000</guid>
		<dc:creator>MythTW</dc:creator>
	</item>
	<item>
		<title>Re: Understanding handle leaks and how to use !htrace to find them</title>
		<description>
			<![CDATA[ha, using a tool, i can download the wmv file and finally be able to watch it.<br>
Going to play with this method on my machine now...<br>
thanks for the tutorial..<p>posted by MythTW</p>]]>
		</description>
		<link>http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them#c633273446070000000</link>
		<pubDate>Sun, 07 Oct 2007 09:03:27 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them#c633273446070000000</guid>
		<dc:creator>MythTW</dc:creator>
	</item>
	<item>
		<title>Re: Understanding handle leaks and how to use !htrace to find them</title>
		<description>
			<![CDATA[
<p>I am alos not able to watch the video ....which tool helped to donwload wmv...?</p>
<p>posted by sang</p>]]>
		</description>
		<link>http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them#c633807306420000000</link>
		<pubDate>Tue, 16 Jun 2009 06:30:42 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them#c633807306420000000</guid>
		<dc:creator>sang</dc:creator>
	</item>
	<item>
		<title>Re: Understanding handle leaks and how to use !htrace to find them</title>
		<description>
			<![CDATA[
<p>&nbsp;</p>
<p>You can click on the &quot;Formats:&quot; drop-down and in the list, right-click the WMV and choose &quot;Save-As&quot;. At least that worked for me. This was the direct link from that:</p>
<p><a href="http://mschnlnine.vo.llnwd.net/d1/ch9/1/2/6/7/5/2/341851_leakyhandles.wmv">http://mschnlnine.vo.llnwd.net/d1/ch9/1/2/6/7/5/2/341851_leakyhandles.wmv</a></p>
<p>posted by c0decafe</p>]]>
		</description>
		<link>http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them#c633837925590000000</link>
		<pubDate>Tue, 21 Jul 2009 17:02:39 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them#c633837925590000000</guid>
		<dc:creator>c0decafe</dc:creator>
	</item>
	<item>
		<title>Re: Understanding handle leaks and how to use !htrace to find them</title>
		<description>
			<![CDATA[Hi, that video was very helpful, thanks for that Jeff. And thanks to c0decafe for the download link.<p>posted by anonymous</p>]]>
		</description>
		<link>http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them#c634256567690000000</link>
		<pubDate>Thu, 18 Nov 2010 05:59:29 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Blogs/jeff_dailey/Understanding-handle-leaks-and-how-to-use-htrace-to-find-them#c634256567690000000</guid>
		<dc:creator>anonymous</dc:creator>
	</item>
</channel>
</rss>