char * LargeHeapBucket::SnailAlloc(Recycler * recycler, size_t sizeCat, size_t size, ObjectInfoBits attributes, bool nothrow) { char * memBlock; Assert((attributes & InternalObjectInfoBitMask) == attributes); // No free memory, try to collect with allocated bytes and time heuristic, and concurrently #if ENABLE_CONCURRENT_GC BOOL collected = recycler->disableCollectOnAllocationHeuristics ? recycler->FinishConcurrent<FinishConcurrentOnAllocation>() : recycler->CollectNow<CollectOnAllocation>(); #else BOOL collected = recycler->disableCollectOnAllocationHeuristics ? FALSE : recycler->CollectNow<CollectOnAllocation>(); #endif if (!collected) { memBlock = TryAllocFromNewHeapBlock(recycler, sizeCat, size, attributes, nothrow); if (memBlock != nullptr) { return memBlock; } // Can't even allocate a new block, we need force a collection and // allocate some free memory, add a new heap block again, or throw out of memory AllocationVerboseTrace(recycler->GetRecyclerFlagsTable(), _u("LargeHeapBucket::AddLargeHeapBlock failed, forcing in-thread collection\n")); recycler->CollectNow<CollectNowForceInThread>(); } memBlock = TryAlloc(recycler, sizeCat, attributes); if (memBlock != nullptr) { return memBlock; } memBlock = TryAllocFromNewHeapBlock(recycler, sizeCat, size, attributes, nothrow); if (memBlock != nullptr) { return memBlock; } if (nothrow == false) { // Can't add a heap block, we are out of memory // Since nothrow is false, we can throw right here recycler->OutOfMemory(); } return nullptr; }
extern void * MemAlloc( unsigned size ) /*************************************/ { void *ptr; #ifdef TRACKER void (*ra)(); ra = FindRet(); /* must be first thing */ ptr = DoLAlloc( size, ra ); #else ptr = TryAlloc( size ); #endif if( ptr == NULL ) { Error( "Dynamic Memory Exhausted!!!" ); } return( ptr ); }