几个月前,我们设法内存泄漏很少,实际上只有3:
内存泄漏n°368是一个未删除的单身,现在已经消失了。 但是其他两个都无法访问,_CrtSetBreakAlloc *的索引不足以捕获它们。 即使是真的伤心了,让他们活着,我们并不在乎在那个时候。
然后,我们更新了一个由我们的软件(Poet / FastObject / Versant / Actian)使用的库,之后......:
我们设法有大约950个内存泄漏,但是没有断点可以访问..
有人知道如何跟踪它们吗?我们试图进入全局变量初始化循环(通过_initterm),但即便如此,我们也无法获得足够低的索引来打破这些内存泄漏。
(*)我们使用这段代码来获取索引并设置断点:
typedef struct _CrtMemBlockHeader
{
// Pointer to the block allocated just before this one:
struct _CrtMemBlockHeader *pBlockHeaderNext;
// Pointer to the block allocated just after this one:
struct _CrtMemBlockHeader *pBlockHeaderPrev;
char *szFileName; // File name
int nLine; // Line number
size_t nDataSize; // Size of user block
int nBlockUse; // Type of block
long lRequest; // Allocation number
// Buffer just before (lower than) the user's memory:
unsigned char gap[4];
} _CrtMemBlockHeader;
static long memoryBlocIndex=0;
void HKERNEL_API CheckMemoryBlocIndex() {
char* c=new char();
_CrtMemBlockHeader* mbh=reinterpret_cast<_CrtMemBlockHeader*>(c-32);
memoryBlocIndex=mbh->lRequest;
TRACE1("\nMemBlockHeader index : %ld\n\n",memoryBlocIndex);
delete c;
int brkValue, memoryIndex;
std::ifstream debugfile("breakpoint.txt");
if (debugfile) {
std::istringstream streamLine;
std::string sline;
std::getline(debugfile, sline);
streamLine.str(sline);
streamLine >> memoryIndex >> brkValue;
if (brkValue > 0) {
BreakAt(brkValue, memoryIndex);
}
}
}
void HKERNEL_API BreakAt(long request, long notifiedMemoryBlocIndex) {
_CrtSetBreakAlloc((request-notifiedMemoryBlocIndex)+memoryBlocIndex);
}
谢谢! Sbizz