#include <folly/memory/JemallocNodumpAllocator.h>
#include <folly/Conv.h>
#include <folly/String.h>
#include <folly/memory/Malloc.h>
#include <glog/logging.h>
namespace folly {
JemallocNodumpAllocator::JemallocNodumpAllocator(State state) { … }
bool JemallocNodumpAllocator::extend_and_setup_arena() { … }
void* JemallocNodumpAllocator::allocate(size_t size) { … }
void* JemallocNodumpAllocator::reallocate(void* p, size_t size) { … }
#ifdef FOLLY_JEMALLOC_NODUMP_ALLOCATOR_SUPPORTED
#ifdef FOLLY_JEMALLOC_NODUMP_ALLOCATOR_CHUNK
chunk_alloc_t* JemallocNodumpAllocator::original_alloc_ = nullptr;
void* JemallocNodumpAllocator::alloc(
void* chunk,
#else
extent_hooks_t JemallocNodumpAllocator::extent_hooks_;
extent_alloc_t* JemallocNodumpAllocator::original_alloc_ = nullptr;
void* JemallocNodumpAllocator::alloc(
extent_hooks_t* extent,
void* new_addr,
#endif
size_t size,
size_t alignment,
bool* zero,
bool* commit,
unsigned arena_ind) {
void* result = original_alloc_(
JEMALLOC_CHUNK_OR_EXTENT,
#ifdef FOLLY_JEMALLOC_NODUMP_ALLOCATOR_EXTENT
new_addr,
#endif
size,
alignment,
zero,
commit,
arena_ind);
if (result != nullptr) {
if (auto ret = madvise(result, size, MADV_DONTDUMP)) {
VLOG(1) << "Unable to madvise(MADV_DONTDUMP): " << errnoStr(ret);
}
}
return result;
}
#endif
void JemallocNodumpAllocator::deallocate(void* p, size_t) { … }
void JemallocNodumpAllocator::deallocate(void* p, void* userData) { … }
JemallocNodumpAllocator& globalJemallocNodumpAllocator() { … }
}