49 virtual void*
allocate(
size_t size) = 0;
58 #include <folly/Memory.h>
59 #include <folly/memory/Arena.h>
61 using AllocatorType = char;
64 folly::Arena<::SysAllocator<AllocatorType>>::kBlockOverhead;
70 class DramArena :
public Arena,
public folly::Arena<::SysAllocator<AllocatorType>> {
72 explicit DramArena(
size_t min_block_size = static_cast<size_t>(1ULL << 32) +
74 size_t size_limit = kNoSizeLimit,
75 size_t max_align = kDefaultMaxAlign)
82 void*
allocate(
size_t size)
override {
83 return folly::Arena<::SysAllocator<AllocatorType>>
::allocate(size);
88 std::memset(ret, 0, size);
93 return folly::Arena<::SysAllocator<AllocatorType>>
::bytesUsed();
97 return folly::Arena<::SysAllocator<AllocatorType>>::totalSize();
104 struct folly::ArenaAllocatorTraits<::
SysAllocator<AllocatorType>> {
105 static size_t goodSize(const ::SysAllocator<AllocatorType>& ,
size_t size) {
106 return folly::goodMallocSize(size);
121 explicit DramArena(
size_t min_block_size = 1ULL << 32,
size_t size_limit = 0)
143 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
virtual size_t totalBytes() const =0
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)
size_t totalBytes() const override
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