本文整理汇总了C++中HeapBlock::IsLargeHeapBlock方法的典型用法代码示例。如果您正苦于以下问题:C++ HeapBlock::IsLargeHeapBlock方法的具体用法?C++ HeapBlock::IsLargeHeapBlock怎么用?C++ HeapBlock::IsLargeHeapBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HeapBlock
的用法示例。
在下文中一共展示了HeapBlock::IsLargeHeapBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Assert
//=====================================================================================================
// Free
//=====================================================================================================
void
LargeHeapBucket::ExplicitFree(void * object, size_t sizeCat)
{
Assert(HeapInfo::GetMediumObjectAlignedSizeNoCheck(sizeCat) == this->sizeCat);
LargeObjectHeader * header = LargeHeapBlock::GetHeaderFromAddress(object);
Assert(header->GetAttributes(this->heapInfo->recycler->Cookie) == ObjectInfoBits::NoBit || header->GetAttributes(this->heapInfo->recycler->Cookie) == ObjectInfoBits::LeafBit);
Assert(!header->isExplicitFreed);
DebugOnly(header->isExplicitFreed = true);
Assert(header->objectSize >= sizeCat);
#if DBG
HeapBlock* heapBlock = this->GetRecycler()->FindHeapBlock(object);
Assert(heapBlock != nullptr);
Assert(heapBlock->IsLargeHeapBlock());
LargeHeapBlock * largeHeapBlock = (LargeHeapBlock *)heapBlock;
LargeObjectHeader * dbgHeader;
Assert(largeHeapBlock->GetObjectHeader(object, &dbgHeader));
Assert(dbgHeader == header);
#endif
FreeObject * freeObject = (FreeObject *)object;
freeObject->SetNext(this->explicitFreeList);
this->explicitFreeList = freeObject;
header->SetAttributes(this->heapInfo->recycler->Cookie, ObjectInfoBits::LeafBit); // We can stop scanning it now.
}
示例2: if
void
SmallHeapBlockAllocator<TBlockType>::Clear()
{
TBlockType * heapBlock = this->heapBlock;
if (heapBlock != nullptr)
{
Assert(heapBlock->isInAllocator);
heapBlock->isInAllocator = false;
FreeObject * remainingFreeObjectList = nullptr;
if (this->endAddress != nullptr)
{
#ifdef RECYCLER_TRACK_NATIVE_ALLOCATED_OBJECTS
TrackNativeAllocatedObjects();
lastNonNativeBumpAllocatedBlock = nullptr;
#endif
#ifdef PROFILE_RECYCLER_ALLOC
// Need to tell the tracker
this->bucket->heapInfo->recycler->TrackUnallocated((char *)this->freeObjectList, this->endAddress, this->bucket->sizeCat);
#endif
RecyclerMemoryTracking::ReportUnallocated(this->heapBlock->heapBucket->heapInfo->recycler, (char *)this->freeObjectList, this->endAddress, heapBlock->heapBucket->sizeCat);
#ifdef RECYCLER_PERF_COUNTERS
size_t unallocatedObjects = heapBlock->objectCount - ((char *)this->freeObjectList - heapBlock->address) / heapBlock->objectSize;
size_t unallocatedObjectBytes = unallocatedObjects * heapBlock->GetObjectSize();
RECYCLER_PERF_COUNTER_ADD(LiveObject, unallocatedObjects);
RECYCLER_PERF_COUNTER_ADD(LiveObjectSize, unallocatedObjectBytes);
RECYCLER_PERF_COUNTER_SUB(FreeObjectSize, unallocatedObjectBytes);
RECYCLER_PERF_COUNTER_ADD(SmallHeapBlockLiveObject, unallocatedObjects);
RECYCLER_PERF_COUNTER_ADD(SmallHeapBlockLiveObjectSize, unallocatedObjectBytes);
RECYCLER_PERF_COUNTER_SUB(SmallHeapBlockFreeObjectSize, unallocatedObjectBytes);
#endif
Assert(heapBlock->freeObjectList == nullptr);
this->endAddress = nullptr;
}
else
{
remainingFreeObjectList = this->freeObjectList;
heapBlock->freeObjectList = remainingFreeObjectList;
}
this->freeObjectList = nullptr;
// this->freeObjectList and this->lastFreeCount are accessed in SmallHeapBlock::ResetMarks
// the order of access there is first we see if lastFreeCount = 0, and if it is, we assert
// that freeObjectList = null. Because of ARM's memory model, we need to insert barriers
// so that the two variables can be accessed correctly across threads. Here, after we write
// to this->freeObjectList, we insert a write barrier so that if this->lastFreeCount is 0,
// this->freeObjectList must have been set to null. On the other end, we stick a read barrier
// We use the MemoryBarrier macro because of ARMs lack of a separate read barrier
#if defined(_M_ARM32_OR_ARM64)
#if DBG
MemoryBarrier();
#endif
#endif
if (remainingFreeObjectList == nullptr)
{
uint lastFreeCount = heapBlock->GetAndClearLastFreeCount();
heapBlock->heapBucket->heapInfo->uncollectedAllocBytes += lastFreeCount * heapBlock->GetObjectSize();
Assert(heapBlock->lastUncollectedAllocBytes == 0);
DebugOnly(heapBlock->lastUncollectedAllocBytes = lastFreeCount * heapBlock->GetObjectSize());
}
else
{
DebugOnly(heapBlock->SetIsClearedFromAllocator(true));
}
this->heapBlock = nullptr;
RECYCLER_SLOW_CHECK(heapBlock->CheckDebugFreeBitVector(false));
}
else if (this->freeObjectList != nullptr)
{
// Explicit Free Object List
#ifdef RECYCLER_MEMORY_VERIFY
FreeObject* freeObject = this->freeObjectList;
while (freeObject)
{
HeapBlock* heapBlock = this->bucket->GetRecycler()->FindHeapBlock((void*) freeObject);
Assert(heapBlock != nullptr);
Assert(!heapBlock->IsLargeHeapBlock());
TBlockType* smallBlock = (TBlockType*)heapBlock;
smallBlock->ClearExplicitFreeBitForObject((void*) freeObject);
freeObject = freeObject->GetNext();
}
#endif
this->freeObjectList = nullptr;
}
}