Commit 46ea0147 authored by Vladimir Marko's avatar Vladimir Marko
Browse files

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

In addition to the initial CL
    (cherry picked from commit 3e0e7173)
this contains a squashed subsequent fix
    Fix valgrind tests: mark allocated space as defined.
    (cherry picked from commit 3f84f2cb)

Change-Id: Id80d5601874e8e28d930c0dd47a51c73c4810094
parent ff2d53a1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment