gpt4 book ai didi

CreateThread 句柄泄漏

转载 作者:太空宇宙 更新时间:2023-11-04 02:15:09 24 4
gpt4 key购买 nike

CreateThread 返回一个HANDLE 对象,需要通过CloseHandle

关闭

文档指出,线程对象保留在系统中,直到线程终止并且通过调用 CloseHandle 关闭线程的所有句柄。

我的问题是如果不使用返回变量会发生什么。它等于不关闭返回的句柄并因此导致句柄泄漏?是这样吗?

最佳答案

这等于不关闭返回的句柄并因此导致句柄泄漏?是这样吗?

是的,您将泄漏操作系统资源,这类似于内存泄漏时泄漏内存。

引用:
<强> MSDN Documentation :

Closing a thread handle does not terminate the associated thread or remove the thread object. Closing a process handle does not terminate the associated process or remove the process object. To remove a thread object, you must terminate the thread, then close all handles to the thread.

关于CreateThread 句柄泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9007810/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com