![]() |
Grep Leaks Memory |
Post Reply ![]() |
Author | |
danpetitt ![]() Senior Member ![]() Joined: 17 July 2005 Location: United Kingdom Status: Offline Points: 109 |
![]() ![]() ![]() ![]() ![]() Posted: 14 September 2006 at 2:23am |
I have 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.
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!
Which is why I tried the Grep sample knowing that uses CWinThread as well and it suffers the same.
To give the thread time to cleanup I added this to MainFrame::OnClose
But the thread gets ExitInstance called but the finished message never arrives so this loop never exits.
Any ideas on why and the solution please?
Thanks.
|
|
![]() |
|
Oleg ![]() Senior Member ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hello,
Thank you for this note.
Code you need is:
if (m_pSearchThread)
{ m_pSearchThread->m_bCancel = TRUE; WaitForSingleObject(m_pSearchThread->m_hThread, INFINITE); m_pSearchThread = NULL;
} |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
danpetitt ![]() Senior Member ![]() Joined: 17 July 2005 Location: United Kingdom Status: Offline Points: 109 |
![]() ![]() ![]() ![]() ![]() |
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. 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):
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |