64,637
社区成员
发帖
与我相关
我的任务
分享
const int gnLoopCounts = 40000;
void testFreeAsStack(PMalloc _alloc, PFree _free)
{
vector<void*> vctPointer;
vctPointer.reserve(gnLoopCounts);
int i=0;
for (; i<gnLoopCounts; ++i)
{
void* pMem = _alloc(i+1);
if (NULL != pMem)
{
vctPointer.push_back(pMem);
memset(pMem, 0, i+1);
}
}
for (i=vctPointer.size()-1; i>=0; --i)
{
_free(vctPointer[i]);
}
}
不管是Debug还是Release都存在此现象, 在_alloc, _free中计算2个函数的时间,并累加。