MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / FreeCache

Method FreeCache

paddle/phi/core/memory/allocation/buffered_allocator.cc:36–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34BufferedAllocator::~BufferedAllocator() { FreeCache(-1UL); }
35
36void BufferedAllocator::FreeCache(size_t size) {
37 platform::LockGuardPtr<std::mutex> guard(mtx_);
38 if (UNLIKELY(size == 0)) return;
39 size_t cur = 0;
40 while (!allocations_.empty()) { // free the largest
41 auto it = --allocations_.end();
42 cur += it->second->size();
43 underlying_allocator_->Free(it->second.release());
44 allocations_.erase(it);
45 if (cur >= size) return;
46 }
47}
48
49bool BufferedAllocator::IsAllocThreadSafe() const { return mtx_ != nullptr; }
50

Callers

nothing calls this directly

Calls 6

emptyMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
FreeMethod · 0.45
releaseMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected