win32 api,vc,利用TerminateProcess终止进程,是否会引起内存资源泄漏?
有没有比较可靠的证据说明这个问题,最好是有微软的权威说明。

解决方案 »

  1.   

    跨进程的资源不会(比如创建一个全局的互斥体)。属于这个进程的资源就会(new 或者malloc分配的内存,打开文件啥的)。
      

  2.   

    好好看看MSDN上的解释,就不用我翻译了吧
    The TerminateProcess function is used to unconditionally cause a process to exit. Use it only in extreme circumstances. The state of global data maintained by dynamic-link libraries (DLLs) may be compromised if TerminateProcess is used rather than ExitProcess. TerminateProcess causes all threads within a process to terminate, and causes a process to exit, but DLLs attached to the process are not notified that the process is terminating. Terminating a process causes the following: All of the object handles opened by the process are closed. 
    All of the threads in the process terminate their execution. 
    The state of the process object becomes signaled, satisfying any threads that had been waiting for the process to terminate. 
    The states of all threads of the process become signaled, satisfying any threads that had been waiting for the threads to terminate. 
    The termination status of the process changes from STILL_ACTIVE to the exit value of the process. 
    Terminating a process does not cause child processes to be terminated. Terminating a process does not necessarily remove the process object from the system. A process object is deleted when the last handle to the process is closed. Terminating a process does not generate notifications for WH_CBT hook procedures. 
      

  3.   

    All of the object handles opened by the process are closed.
    All of the threads in the process terminate their execution. Use it only in extreme circumstances
      

  4.   

    这个不会的。“程序都死了,一切都尘归尘、土归土了。难道还怕人家来盗墓不成?” http://www.skinsharp.com
      

  5.   

    《WINDOWS核心编程》里说不会泄漏.不知道算不算权威。