| 656 | } |
| 657 | |
| 658 | size_t BatchAllocateRaw(size_t num, size_t alignment, |
| 659 | size_t num_bytes, void** ret) override { |
| 660 | num_bytes = AlignedSize(num_bytes); |
| 661 | |
| 662 | if (num_bytes > kChunkSize) { |
| 663 | LOG(FATAL) << "Allocation of " << num_bytes << " exceeds " |
| 664 | << kChunkSize << " in EVAllocator."; |
| 665 | } |
| 666 | |
| 667 | auto allocated_num = impl_.BatchAllocate(num, num_bytes, ret); |
| 668 | if (allocated_num == 0) { |
| 669 | LOG(WARNING) << "Can't allocate num:" |
| 670 | << num << ", num_bytes:" << num_bytes; |
| 671 | return 0; |
| 672 | } |
| 673 | |
| 674 | if (ev_allocator_collect_stats) { |
| 675 | auto p = ret[0]; |
| 676 | const std::size_t alloc_size = impl_.AllocatedSize(p); |
| 677 | mutex_lock l(mu_); |
| 678 | stats_.num_allocs += allocated_num; |
| 679 | stats_.bytes_in_use += alloc_size * allocated_num; |
| 680 | stats_.peak_bytes_in_use = |
| 681 | std::max<int64>(stats_.peak_bytes_in_use, stats_.bytes_in_use); |
| 682 | stats_.largest_alloc_size = |
| 683 | std::max<int64>(stats_.largest_alloc_size, alloc_size); |
| 684 | } |
| 685 | return allocated_num; |
| 686 | } |
| 687 | |
| 688 | void DeallocateRaw(void* ptr) override { |
| 689 | if (ev_allocator_collect_stats) { |
nothing calls this directly
no test coverage detected