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

Method DoClear

util/memory/pool.cpp:31–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31size_t TMemoryPool::DoClear(bool keepfirst) noexcept {
32 size_t chunksUsed = 0;
33 while (!Chunks_.Empty()) {
34 chunksUsed += 1;
35 TChunk* c = Chunks_.PopBack();
36
37 if (keepfirst && Chunks_.Empty()) {
38 c->ResetChunk();
39 Chunks_.PushBack(c);
40 Current_ = c;
41 BlockSize_ = c->BlockLength() - sizeof(TChunk);
42 MemoryAllocatedBeforeCurrent_ = 0;
43 MemoryWasteBeforeCurrent_ = 0;
44 return chunksUsed;
45 }
46
47 TBlock b = {c, c->BlockLength()};
48
49 c->~TChunk();
50 Alloc_->Release(b);
51 }
52
53 Current_ = &Empty_;
54 BlockSize_ = Origin_;
55 MemoryAllocatedBeforeCurrent_ = 0;
56 MemoryWasteBeforeCurrent_ = 0;
57 return chunksUsed;
58}

Callers

nothing calls this directly

Calls 7

ResetChunkMethod · 0.80
BlockLengthMethod · 0.80
~TChunkMethod · 0.80
EmptyMethod · 0.45
PopBackMethod · 0.45
PushBackMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected