MCPcopy Create free account
hub / github.com/catboost/catboost / LargeBlockFree

Function LargeBlockFree

library/cpp/lfalloc/lf_allocX64.h:510–536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

508#endif
509
510static void LargeBlockFree(void* p, ELFAllocCounter counter) {
511 if (p == nullptr)
512 return;
513#ifdef _MSC_VER
514 VirtualFree((char*)p - 4096ll, 0, MEM_RELEASE);
515#else
516 size_t pgCount = TLargeBlk::As(p)->Pages;
517
518 TLargeBlk::As(p)->Mark(ELarge::Free);
519 IncrementCounter(counter, pgCount * 4096ll);
520 IncrementCounter(CT_SYSTEM_FREE, 4096ll);
521
522 if (lbFreePageCount > LB_LIMIT_TOTAL_SIZE)
523 FreeAllLargeBlockMem();
524 int lbHash = pgCount % LB_BUF_HASH;
525 for (int i = 0; i < LB_BUF_SIZE; ++i) {
526 if (lbFreePtrs[lbHash][i] == nullptr) {
527 if (DoCas(&lbFreePtrs[lbHash][i], p, (void*)nullptr) == nullptr) {
528 AtomicAdd(lbFreePageCount, pgCount);
529 return;
530 }
531 }
532 }
533
534 LargeBlockUnmap(p, pgCount);
535#endif
536}
537
538static void* SystemAlloc(size_t _nSize) {
539 //HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, _nSize);

Callers 2

SystemFreeFunction · 0.85
LFFreeFunction · 0.85

Calls 6

IncrementCounterFunction · 0.85
FreeAllLargeBlockMemFunction · 0.85
LargeBlockUnmapFunction · 0.85
DoCasFunction · 0.70
AtomicAddFunction · 0.70
MarkMethod · 0.45

Tested by

no test coverage detected