<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Codejock Developer Community : Grep Leaks Memory</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Toolkit Pro : Grep Leaks Memory]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Sat, 13 Jun 2026 05:57:16 +0000</pubDate>
  <lastBuildDate>Thu, 14 Sep 2006 06:23:19 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.04</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>forum.codejock.com/RSS_post_feed.asp?TID=5045</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Codejock Developer Community]]></title>
   <url>http://forum.codejock.com/forum_images/codejock-logo.gif</url>
   <link>http://forum.codejock.com/</link>
  </image>
  <item>
   <title><![CDATA[Grep Leaks Memory : Thanks a lot Oleg, I did notice...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=5045&amp;PID=15691&amp;title=grep-leaks-memory#15691</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=1322">danpetitt</a><br /><strong>Subject:</strong> 5045<br /><strong>Posted:</strong> 14 September 2006 at 6:23am<br /><br /><P>Thanks a lot Oleg, I did notice that I had to use a member variable for the thread handle and use DuplicateHandle so its not closed before I can investigate it.</P><DIV>As it uses messages to indicate to the primary thread that it has finished, I had to add a message pump in the wait, so I ended up with (something like):</DIV><DIV>&nbsp;</DIV><DIV><table width="99%"><tr><td><pre class="BBcode">HANDLE m_myDuplicateThreadHandle;<BR>VERIFY( ::DuplicateHandle( GetCurrentProcess(), m_pSearchThread-&gt;m_hThread, GetCurrentProcess(), &amp;m_myDuplicateThreadHandle, 0, FALSE, DUPLICATE_SAME_ACCESS ) );</DIV><DIV><BR>while( ::WaitForSingleObject( m_myDuplicateThreadHandle, 10 ) == WAIT_TIMEOUT )<BR>{<BR>&nbsp;MSG msg;<BR>&nbsp;while( ::PeekMessage( &amp;msg, NULL, 0, 0, PM_NOREMOVE ) )<BR>&nbsp;{<BR>&nbsp;if( !AfxGetApp()-&gt;PumpMessage() )<BR>&nbsp;{<BR>&nbsp; ::PostQuitMessage( 0 );<BR>&nbsp; break;<BR>&nbsp;}<BR>&nbsp;}<BR>&nbsp;LONG lIdle = 0;<BR>&nbsp;while( AfxGetApp()-&gt;OnIdle( lIdle++ ) );</DIV><DIV>&nbsp;Sleep( 0 );<BR>}</DIV><DIV>CloseHandle( m_myDuplicateThreadHandle );</pre></td></tr></table></DIV>]]>
   </description>
   <pubDate>Thu, 14 Sep 2006 06:23:19 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=5045&amp;PID=15691&amp;title=grep-leaks-memory#15691</guid>
  </item> 
  <item>
   <title><![CDATA[Grep Leaks Memory : Hello, Thank you for this note.  Code...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=5045&amp;PID=15688&amp;title=grep-leaks-memory#15688</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 5045<br /><strong>Posted:</strong> 14 September 2006 at 3:56am<br /><br />Hello,<DIV>Thank you for this note.</DIV><DIV>&nbsp;</DIV><DIV>Code you need is:</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;if (m_pSearchThread)<BR>&nbsp;{<BR>&nbsp;&nbsp;m_pSearchThread-&gt;m_bCancel = TRUE;<BR>&nbsp;&nbsp;WaitForSingleObject(m_pSearchThread-&gt;m_hThread, INFINITE);</DIV><DIV>&nbsp;&nbsp;m_pSearchThread = NULL;<BR>&nbsp;}</DIV>]]>
   </description>
   <pubDate>Thu, 14 Sep 2006 03:56:54 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=5045&amp;PID=15688&amp;title=grep-leaks-memory#15688</guid>
  </item> 
  <item>
   <title><![CDATA[Grep Leaks Memory : I havethe same problem in my own...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=5045&amp;PID=15684&amp;title=grep-leaks-memory#15684</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=1322">danpetitt</a><br /><strong>Subject:</strong> 5045<br /><strong>Posted:</strong> 14 September 2006 at 2:23am<br /><br />I have&nbsp;the same problem in my own app, but with the Grep sample if you start a search and exit the application while the search is executing the ExitInstance doesnt get called and the objects leak. <DIV>&nbsp;</DIV><DIV>What's the solution as I have spent days and rewritten this part of my app 6 times and I still get the same problem. I have tried waiting in MainFrame::OnClose until thread finishes but it never does, argh!</DIV><DIV>&nbsp;</DIV><DIV>Which is why I tried the Grep sample knowing that uses CWinThread as well and it suffers the same.</DIV><DIV>&nbsp;</DIV><DIV>To give the thread time to cleanup I added this to MainFrame::OnClose</DIV><DIV><table width="99%"><tr><td><pre class="BBcode">&nbsp;if( m_pSearchThread )<BR>&nbsp;{<BR>&nbsp;&nbsp;m_pSearchThread-&gt;m_bCancel = TRUE;<BR>&nbsp;&nbsp;while( m_pSearchThread )<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;Sleep( 1000 );<BR>&nbsp;&nbsp;}<BR>&nbsp;}</DIV><DIV></pre></td></tr></table></DIV><DIV>&nbsp;</DIV><DIV>But the thread gets ExitInstance called but the finished message never arrives so this loop never exits.</DIV><DIV>&nbsp;</DIV><DIV>Any ideas on why and the solution please?</DIV><DIV>&nbsp;</DIV><DIV>Thanks.</DIV>]]>
   </description>
   <pubDate>Thu, 14 Sep 2006 02:23:51 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=5045&amp;PID=15684&amp;title=grep-leaks-memory#15684</guid>
  </item> 
 </channel>
</rss>