C++???????й??????
???????????? ???????[ 2014/10/30 11:20:41 ] ????????c++ ??? NET ???????
?????????
??????????c++????????й???
????????
???????????easy???????????????????????????ó????new?? new[] ?? delete ?? delete[]?? malloc??calloc??free??????????????
???????:
?????????????????У???????????????????????????????????????????涯?????????????????Ч?????????????????????
????1????????????????????????????
//????????????????????????
typedef struct _tagMemoryInfo
{
void* addr; //?????????????
size_t size; //????С
_UL lineNum; //?????????亯?????к?
char fileName[MAX_FILE_LEN]; //?????
}MemoryInfo;
//???????????????????????????????union????????????next????????
union FreeList
{
FreeList* next;
MemoryInfo data;
};
????2????????????????????????
typedef struct _tagBusyList
{
_tagBusyList* next;
MemoryInfo* data;
}BusyList;
????????
????1??????????vc2005???????????????????????????
????2?????????????????п???????
????3?????浱?????????????????????next??ε???濪????
???????
????1??????
#ifdef DETECT_MEMORY_LEAK
#ifndef _DETECT_MEMORY_LEAK_H_
#define _DETECT_MEMORY_LEAK_H_
typedef unsigned long _UL;
void* __cdecl operator new(unsigned int size ?? _UL lineNum ?? const char* file);
void* __cdecl operator new[](unsigned int size ?? _UL lineNum ?? const char* file);
void __cdecl operator delete(void *p);
void __cdecl operator delete [] (void *p);
void __cdecl operator delete(void *p ?? _UL lineNum ?? const char* file);
void __cdecl operator delete [] (void *p ?? _UL lineNum ?? const char* file);
void* __cdecl _DebugMalloc(size_t size ?? _UL lineNum ?? const char* file);
void* __cdecl _DebugCalloc(size_t num ?? size_t size ?? _UL lineNum ?? const char* file);
void __cdecl _DebugFree(void* addr);
#ifndef DETECT_MEMORY_LEAK_IMPL
#define new DEBUG_NEW
#define DEBUG_NEW new(__LINE__ ?? __FILE__)
#define malloc DEBUG_MALLOC
#define DEBUG_MALLOC(x) _DebugMalloc(x ?? __LINE__ ?? __FILE__)
#define calloc DEBUG_CALLOC
#define DEBUG_CALLOC(x) _DebugCalloc(x ?? __LINE__ ?? __FILE__)
#define free DEBUG_FREE
#define DEBUG_FREE(x) _DebugFree(x)
#endif
void DumpLeakedMemoryInfo();
#endif//_DETECT_MEMORY_LEAK_H_
#endif//DETECT_MEMORY_LEAK
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11