内存资源释放

1.内存泄露

eg:  BYTE *pBuffer=new BYTE[100];

释放:delete [] pBuffer;


2.文件资源泄露

eg:   File *pFile=fopen("test.txt");

释放:fclose(pFile);


3.GDI泄露

eg:   HDC hDC=::GetDC(hWnd);

释放:ReleaseDC(hDC);


4.信号资源泄露

eg:   HANDLE hMute=::CreateMutex(NULL,TRUE,"MuteSignal");

释放:CloseHandle(hMute);


5.访问溢出(Memory Overrun错误)

eg:   char ch[4]="world";

修改:char ch[5]="world";



相关文章
相关标签/搜索