Reputation: 41
One of my executable is opening about 330 handles when it is run alone. Where as when it is run in combination with another specific process, it is leaking many handles.
I have used 'handle' utility from sysinternals to check what are all the handles open in both cases. When this process is run in combination with other specific process it is having the following handle entry's extra.
578: Process
57C: Thread
580: Process
584: Thread
588: Process
58C: Thread
590: Event
598: Process
59C: Thread
5A0: Process
5A4: Thread
5A8: Process
5AC: Thread
5B0: Process
5B4: Thread
5B8: Event
This way it has 400 extra handles opened for Process, Thread, Event. Eventually this leak is causing the application to crash.
I am new to windows programming, please excuse me I am asking very basic questions. I will really appreciate any help/ suggestion in this regard.
Upvotes: 2
Views: 3156
Reputation: 941455
It's a pretty classic bug when using the CreateProcess() function. The last argument, lpProcessInformation, gives you a PROCESS_INFORMATION back. You have to call CloseHandle() on the returned hProcess and hThread members if you are not interested in them.
Upvotes: 10