0
点赞
收藏
分享

微信扫一扫

VC中所有内存,句柄,文件,组件的申请释放函数


VC中所有内存,句柄,文件,组件的申请释放函数

​​编者:李国帅​​


背景原因:

当初为了排查内存泄漏进行了总结

 

所需资源:

Vc

具体类型:

SAFE_DEL                           new                                                                                     delete
SAFE_DELARY new [] delete[]
SAFE_HEAPFREE HeapCreate,HeapAlloc,HeapReAlloc HeapFree,HeapDestroy
VirtualAlloc,VirtualAllocEx VirtualFree,VirtualFreeEx
LocalAlloc,LocalReAlloc LocalFree
SAFE_GLOBALFREE GlobalAlloc,GlobalReAlloc GlobalFree
SAFE_FREE calloc,malloc,realloc free
SAFE_CLOSEFILE _sopen,fdopen,fopen fclose,fcloseall
SAFE_CLOSEHANDLE Create**(同步及线程,GDI对象,文件) CloseHandle
CreateFile,FindFirstFile
OpenFile,ReOpenFile
OpenFileMapping,CreateFileMapping
FindFirstStream,FindNextStream

OpenThread,CreateThread,CreateRemoteThread
OpenProcess,CreateProcess
OpenSemaphore,CreateSemaphore (WaitFor*** ReleaseSemaphore)
OpenEvent,CreateEvent (WaitFor*** ResetEvent )
OpenMutex,CreateMutex (WaitFor*** ReleaseMutex )
CreateNamedPipe,OpenWaitableTimer

SAFE_DEL_HWND Create(窗口) DestroyWindow
CAMThread::Create不需要destroy
CImageList(等GDI控件类)::Create不需要DestroyWindow

SAFE_DEL_HGDI CreateCompatibleDC,CreateDC DeleteDC
GetDC ReleaseDC
CreateMetaFile DeleteMetaFile
CDC,CPen,CRect,CRng等MFC类是不需要delete的

CreateDIBPatternBrush,CreateBrush DeleteObject
CreateSolidBrush,CreateIC
CreateCompatibleBitmap
CreateBitmap,CreateDIBitmap(<16MB)
CreatePalette
CreatePen
CreateFont,CreateFontIndirect
CreateRectRgn,CreateEllipticRgn
CreatePolygonRgn,CreateRoundRectRgn
CreateColorSpace DeleteColorSpace

(without specifying the LR_SHARED )
LoadBitmap DeleteObject
LoadCursor DestroyCursor
LoadIcon DestroyIcon
LoadImage
CreateCursor DestroyCursor

SAFE_RELEASE CoCreateInstance Release
QueryInterface
CreateInstance
CreateObject(所有的接口类,只有不是只能接口都需要release)

 

举报

相关推荐

0 条评论