| 189 | } |
| 190 | |
| 191 | Maybe<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 | |
| 208 | VirtualMachine::~VirtualMachine() { |
| 209 | if (!threads_closed_) { CHECK_JUST(CloseVMThreads()); } |
no test coverage detected