ART: Prune FindArrayClass cache in image writer
The ClassLinker cache speeds up FindArrayClass requests, but all
entries are roots. It is possible that an entry is a non-image
class when creating the boot image, artificially keeping the
class around.
Bug: 21596650
(cherry picked from commit 44905ce1c97613a5cb44046049843fe1029a64cf)
Change-Id: Ief9b439945d0e293a3cb5dcddfeb189b5e174f06
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc
index 11743f3..32bde8e 100644
--- a/compiler/image_writer.cc
+++ b/compiler/image_writer.cc
@@ -718,6 +718,9 @@
// contains data only valid during a real run.
dex_cache->SetFieldObject<false>(mirror::DexCache::DexOffset(), nullptr);
}
+
+ // Drop the array class cache in the ClassLinker, as these are roots holding those classes live.
+ class_linker->DropFindArrayClassCache();
}
bool ImageWriter::NonImageClassesVisitor(Class* klass, void* arg) {