Avoid running Runtime.gc() until we need to run finalization.

This prevents excessive explicit GC which are called from apps to get
good GC behavior on Dalvik. Calling System.gc() does not help on ART
since GC for alloc is much rarer.

If running finalizers is requested following a System.gc we remember
that a GC was requested and perform it ahead of finalization.

based on commit 930e26f0f59c0ce1020524269c82492f3c4ea722

Bug: 12004934
Bug: 26807871
Change-Id: I1a1455b0f3f229d2c507f8330fe6d31d6940ea21
1 file changed