OSDN Git Service

Reduce memory lost by ArenaAllocator for large allocations.
authorVladimir Marko <vmarko@google.com>
Fri, 22 Apr 2016 17:07:13 +0000 (18:07 +0100)
committerVladimir Marko <vmarko@google.com>
Mon, 25 Apr 2016 12:57:56 +0000 (13:57 +0100)
commit3e0e7173c0cdfc57dba39fe781e30d187d50fa9c
tree8552d3f59307098dca69bfbcf64228c2c70c2496
parent4f4a6c47ef269c68bc136f0805e5e99512d970b7
Reduce memory lost by ArenaAllocator for large allocations.

When allocating from a new arena, check if the old arena has
more remaining space than the new one after the current
allocation. If so, keep using the old arena to reduce the
amount of "lost" arena memory. This can happen when we try
to allocate more than half the default arena size. If the
allocation exceeds the default arena size, it's very likely
to happen even though the ArenaPool could still provide some
much larger previously allocated arena.

Also avoid artithmetic overflow when checking if the
request can be satisfied from the current arena.
And abort immediately if calloc() fails.

Bug: 28173563
Bug: 28256882
Change-Id: I1b4bda5d3f32ecd95fbd11addd1f0ca6dcc33e45
build/Android.gtest.mk
compiler/utils/arena_allocator_test.cc [deleted file]
runtime/base/arena_allocator.cc
runtime/base/arena_allocator.h
runtime/base/arena_allocator_test.cc [new file with mode: 0644]