diff options
| -rw-r--r-- | runtime/base/arena_allocator.h | 5 | ||||
| -rw-r--r-- | runtime/base/scoped_arena_allocator.h | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/runtime/base/arena_allocator.h b/runtime/base/arena_allocator.h index ace6c388af..36334c4129 100644 --- a/runtime/base/arena_allocator.h +++ b/runtime/base/arena_allocator.h @@ -288,6 +288,11 @@ class ArenaPool { DISALLOW_COPY_AND_ASSIGN(ArenaPool); }; +// Fast single-threaded allocator for zero-initialized memory chunks. +// +// Memory is allocated from ArenaPool in large chunks and then rationed through +// the ArenaAllocator. It's returned to the ArenaPool only when the ArenaAllocator +// is destroyed. class ArenaAllocator : private DebugStackRefCounter, private ArenaAllocatorStats, private ArenaAllocatorMemoryTool { public: diff --git a/runtime/base/scoped_arena_allocator.h b/runtime/base/scoped_arena_allocator.h index a30c73d749..a87153bd77 100644 --- a/runtime/base/scoped_arena_allocator.h +++ b/runtime/base/scoped_arena_allocator.h @@ -42,6 +42,7 @@ enum class ArenaFreeTag : uint8_t { static constexpr size_t kArenaAlignment = 8; // Holds a list of Arenas for use by ScopedArenaAllocator stack. +// The memory is returned to the ArenaPool when the ArenaStack is destroyed. class ArenaStack : private DebugStackRefCounter, private ArenaAllocatorMemoryTool { public: explicit ArenaStack(ArenaPool* arena_pool); @@ -121,6 +122,12 @@ class ArenaStack : private DebugStackRefCounter, private ArenaAllocatorMemoryToo DISALLOW_COPY_AND_ASSIGN(ArenaStack); }; +// Fast single-threaded allocator. Allocated chunks are _not_ guaranteed to be zero-initialized. +// +// Unlike the ArenaAllocator, ScopedArenaAllocator is intended for relatively short-lived +// objects and allows nesting multiple allocators. Only the top allocator can be used but +// once it's destroyed, its memory can be reused by the next ScopedArenaAllocator on the +// stack. This is facilitated by returning the memory to the ArenaStack. class ScopedArenaAllocator : private DebugStackReference, private DebugStackRefCounter, private ArenaAllocatorStats { public: |