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

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

编者:李国帅

qq:9611153 微信lgs9611153

时间:2012-11-21

背景原因:

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

 

所需资源:

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)

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

微澜-

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值