| 360 | } |
| 361 | |
| 362 | serialization::MemoryPoolObject MemoryPool::saveState() const { |
| 363 | if (!slabAllocator_.isRestorable()) { |
| 364 | throw std::logic_error("Memory Pool can not be restored"); |
| 365 | } |
| 366 | |
| 367 | serialization::MemoryPoolObject object; |
| 368 | |
| 369 | *object.id() = id_; |
| 370 | *object.maxSize() = maxSize_; |
| 371 | *object.currSlabAllocSize() = currSlabAllocSize_; |
| 372 | *object.currAllocSize() = currAllocSize_; |
| 373 | |
| 374 | for (auto slab : freeSlabs_) { |
| 375 | object.freeSlabIdxs()->push_back(slabAllocator_.slabIdx(slab)); |
| 376 | } |
| 377 | |
| 378 | for (auto size : acSizes_) { |
| 379 | object.acSizes()->push_back(size); |
| 380 | } |
| 381 | |
| 382 | for (const std::unique_ptr<AllocationClass>& allocClass : ac_) { |
| 383 | object.ac()->push_back(allocClass->saveState()); |
| 384 | } |
| 385 | |
| 386 | *object.numSlabResize() = nSlabResize_; |
| 387 | *object.numSlabRebalance() = nSlabRebalance_; |
| 388 | *object.numSlabsAdvised() = curSlabsAdvised_; |
| 389 | |
| 390 | return object; |
| 391 | } |
| 392 | |
| 393 | FOLLY_DISABLE_ADDRESS_SANITIZER void memsetNoAsan(void* ptr, |
| 394 | uint8_t c, |