16 #ifndef IMPALA_RUNTIME_MEM_POOL_H
17 #define IMPALA_RUNTIME_MEM_POOL_H
93 return Allocate<false>(size);
101 return Allocate<true>(size);
108 DCHECK_GE(byte_size, 0);
120 for (std::vector<ChunkInfo>::iterator chunk =
chunks_.begin();
121 chunk !=
chunks_.end(); ++chunk) {
122 chunk->cumulative_allocated_bytes = 0;
123 chunk->allocated_bytes = 0;
144 bool Contains(uint8_t* ptr,
int size);
170 void GetChunkInfo(std::vector<std::pair<uint8_t*, int> >* chunk_info);
239 bool FindChunk(
int min_size,
bool check_limits);
255 template <
bool CHECK_LIMIT_FIRST>
257 if (size == 0)
return NULL;
259 int num_bytes = ((size + 7) / 8) * 8;
263 if (CHECK_LIMIT_FIRST) {
265 if (!
FindChunk(num_bytes,
true))
return NULL;
int last_offset_conversion_chunk_idx_
bool CheckIntegrity(bool current_chunk_empty)
int GetFreeOffset() const
Return offset to unoccpied space in current chunk.
MemTracker * mem_tracker_
bool Contains(uint8_t *ptr, int size)
int64_t peak_allocated_bytes() const
int allocated_bytes
bytes allocated via Allocate() in this chunk
bool FindChunk(int min_size, bool check_limits)
uint8_t * GetDataPtr(int offset)
uint8_t * TryAllocate(int size)
int64_t total_allocated_bytes() const
std::vector< ChunkInfo > chunks_
uint8_t * Allocate(int size)
std::string DebugPrint()
Print allocated bytes from all chunks.
int64_t GetTotalChunkSizes() const
Return sum of chunk_sizes_.
void AcquireData(MemPool *src, bool keep_current)
static const int DEFAULT_INITIAL_CHUNK_SIZE
void Clear()
Makes all allocated chunks available for re-use, but doesn't delete any chunks.
void ReturnPartialAllocation(int byte_size)
uint8_t * GetDataPtrHelper(int offset)
int64_t total_allocated_bytes_
sum of allocated_bytes_
int cumulative_allocated_bytes
void GetChunkInfo(std::vector< std::pair< uint8_t *, int > > *chunk_info)
Return (data ptr, allocated bytes) pairs for all chunks owned by this mempool.
MemTracker * mem_tracker()
int64_t peak_allocated_bytes_
Maximum number of bytes allocated from this pool at one time.
int GetCurrentOffset() const
int64_t total_reserved_bytes() const
This class is thread-safe.
static const char * LLVM_CLASS_NAME
MemPool(MemTracker *mem_tracker, int chunk_size=0)
int64_t total_reserved_bytes_
sum of all bytes allocated in chunks_
uint8_t offset[7 *64-sizeof(uint64_t)]
int GetOffset(uint8_t *data)
std::string DebugString()
int GetOffsetHelper(uint8_t *data)
uint8_t * Allocate(int size)