From 88b74b6a4dbbe0b5b75ef1738833e5b064e85d4c Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Sun, 16 Jul 2017 17:08:19 -0700 Subject: Avoid creating compiled_methods_ array unnecessarily For compiler filters that don't quicken or compile, avoid creating the compiled method arrays to save RAM. For a dex2oat of a large app with verify filter -j4 on the host: Reduce native alloc from 39MB to 35MB Maximum resident set size (kbytes): 287592k -> 282696k Bug: 63467744 Test: test-art-host Change-Id: Ib84fd9337dc7f5f1e32017bf2c392d1d3328fba8 --- compiler/driver/compiler_driver.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index bb64755c9e..c04e45d334 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -890,17 +890,18 @@ void CompilerDriver::PreCompile(jobject class_loader, TimingLogger* timings) { CheckThreadPools(); - for (const DexFile* dex_file : dex_files) { - // Can be already inserted if the caller is CompileOne. This happens for gtests. - if (!compiled_methods_.HaveDexFile(dex_file)) { - compiled_methods_.AddDexFile(dex_file); - } - } - LoadImageClasses(timings); VLOG(compiler) << "LoadImageClasses: " << GetMemoryUsageString(false); if (compiler_options_->IsAnyCompilationEnabled()) { + // Avoid adding the dex files in the case where we aren't going to add compiled methods. + // This reduces RAM usage for this case. + for (const DexFile* dex_file : dex_files) { + // Can be already inserted if the caller is CompileOne. This happens for gtests. + if (!compiled_methods_.HaveDexFile(dex_file)) { + compiled_methods_.AddDexFile(dex_file); + } + } // Resolve eagerly to prepare for compilation. Resolve(class_loader, dex_files, timings); VLOG(compiler) << "Resolve: " << GetMemoryUsageString(false); -- cgit v1.2.3-59-g8ed1b