MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / ShrinkAllMem

Method ShrinkAllMem

oneflow/core/vm/virtual_machine.cpp:191–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191Maybe<void> VirtualMachine::ShrinkAllMem() {
192 auto try_shrink_men = [](vm::VirtualMachineEngine* engine) -> bool {
193 if (engine->mut_active_stream_list()->size()) { return false; }
194 INTRUSIVE_FOR_EACH_PTR(thread_ctx, engine->mut_thread_ctx_list()) {
195 INTRUSIVE_FOR_EACH_PTR(stream, thread_ctx->mut_stream_list()) {
196 vm::Allocator* allocator = stream->mut_stream_policy()->mut_allocator();
197 if (allocator) {
198 auto* cache = dynamic_cast<vm::CachingAllocator*>(allocator);
199 if (cache != nullptr) { cache->Shrink(); }
200 }
201 }
202 }
203 return true;
204 };
205 return BlockingRunProbeFunc(try_shrink_men);
206}
207
208VirtualMachine::~VirtualMachine() {
209 if (!threads_closed_) { CHECK_JUST(CloseVMThreads()); }

Callers 4

offloadMethod · 0.80
loadMethod · 0.80
InitRuntimeMethod · 0.80
EmptyCacheFunction · 0.80

Calls 8

mut_thread_ctx_listMethod · 0.80
mut_stream_listMethod · 0.80
ShrinkMethod · 0.80
INTRUSIVE_FOR_EACH_PTRFunction · 0.70
sizeMethod · 0.45
mut_allocatorMethod · 0.45
mut_stream_policyMethod · 0.45

Tested by

no test coverage detected