49 virtual void*
allocate(
size_t size) = 0;
57 #include <folly/Memory.h>
58 #include <folly/memory/Arena.h>
60 using AllocatorType = char;
63 folly::Arena<::SysAllocator<AllocatorType>>::kBlockOverhead;
69 class DramArena :
public Arena,
public folly::Arena<::SysAllocator<AllocatorType>> {
71 explicit DramArena(
size_t min_block_size = static_cast<size_t>(1ULL << 32) +
73 size_t size_limit = kNoSizeLimit,
74 size_t max_align = kDefaultMaxAlign)
81 void*
allocate(
size_t size)
override {
82 return folly::Arena<::SysAllocator<AllocatorType>>
::allocate(size);
87 std::memset(ret, 0, size);
92 return folly::Arena<::SysAllocator<AllocatorType>>
::bytesUsed();
99 struct folly::ArenaAllocatorTraits<::
SysAllocator<AllocatorType>> {
100 static size_t goodSize(const ::SysAllocator<AllocatorType>& ,
size_t size) {
101 return folly::goodMallocSize(size);
116 explicit DramArena(
size_t min_block_size = 1ULL << 32,
size_t size_limit = 0)
138 std::memset(ret, 0, size);
constexpr size_t kArenaBlockOverhead
void * allocate(size_t num_bytes) override
virtual MemoryType getMemoryType() const =0
friend bool operator!=(Self const &, Self const &) noexcept
constexpr SysAllocator()=default
T * allocate(size_t count)
virtual size_t bytesUsed() const =0
void deallocate(T *p, size_t)
virtual void * allocate(size_t size)=0
size_t bytesUsed() const override
void * checked_malloc(const size_t size)
SysAllocator< void > allocator_
constexpr SysAllocator(const SysAllocator< U > &) noexcept
DramArena(size_t min_block_size=1ULL<< 32, size_t size_limit=0)
void * allocateAndZero(const size_t size) override
friend bool operator==(Self const &, Self const &) noexcept
MemoryType getMemoryType() const override
std::vector< std::pair< void *, size_t > > allocations_
virtual void * allocateAndZero(const size_t size)=0