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

Method AddChunk

util/memory/pool.cpp:12–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10}
11
12void TMemoryPool::AddChunk(size_t hint) {
13 const size_t dataLen = Max(BlockSize_, hint);
14 size_t allocSize = dataLen + sizeof(TChunk);
15 if (Options_.RoundUpToNextPowerOfTwo) {
16 allocSize = FastClp2(allocSize);
17 }
18 TBlock nb = Alloc_->Allocate(allocSize);
19
20 // Add previous chunk's stats
21 if (Current_ != &Empty_) {
22 MemoryAllocatedBeforeCurrent_ += Current_->Used();
23 MemoryWasteBeforeCurrent_ += Current_->Left();
24 }
25
26 BlockSize_ = GrowPolicy_->Next(dataLen);
27 Current_ = new (nb.Data) TChunk(nb.Len - sizeof(TChunk));
28 Chunks_.PushBack(Current_);
29}
30
31size_t TMemoryPool::DoClear(bool keepfirst) noexcept {
32 size_t chunksUsed = 0;

Callers

nothing calls this directly

Calls 7

FastClp2Function · 0.85
UsedMethod · 0.80
MaxFunction · 0.50
AllocateMethod · 0.45
LeftMethod · 0.45
NextMethod · 0.45
PushBackMethod · 0.45

Tested by

no test coverage detected