summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/gc/collector/garbage_collector.cc3
-rw-r--r--runtime/parsed_options.cc2
-rw-r--r--runtime/runtime.cc3
-rw-r--r--runtime/runtime.h5
-rw-r--r--runtime/runtime_options.def1
-rwxr-xr-xtools/art8
6 files changed, 18 insertions, 4 deletions
diff --git a/runtime/gc/collector/garbage_collector.cc b/runtime/gc/collector/garbage_collector.cc
index f35be96625..6eacf2c900 100644
--- a/runtime/gc/collector/garbage_collector.cc
+++ b/runtime/gc/collector/garbage_collector.cc
@@ -321,7 +321,8 @@ bool GarbageCollector::ShouldEagerlyReleaseMemoryToOS() const {
if (runtime->IsZygote()) {
return true;
}
- if (GetCurrentIteration()->GetGcCause() == kGcCauseExplicit) {
+ if (GetCurrentIteration()->GetGcCause() == kGcCauseExplicit &&
+ !runtime->IsEagerlyReleaseExplicitGcDisabled()) {
// Our behavior with explicit GCs is to always release any available memory.
return true;
}
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc
index 7df765fe29..140503fd36 100644
--- a/runtime/parsed_options.cc
+++ b/runtime/parsed_options.cc
@@ -341,6 +341,8 @@ std::unique_ptr<RuntimeParser> ParsedOptions::MakeParser(bool ignore_unrecognize
.IntoKey(M::BackgroundGc)
.Define("-XX:+DisableExplicitGC")
.IntoKey(M::DisableExplicitGC)
+ .Define("-XX:+DisableEagerlyReleaseExplicitGC")
+ .IntoKey(M::DisableEagerlyReleaseExplicitGC)
.Define("-Xlockprofthreshold:_")
.WithType<unsigned int>()
.IntoKey(M::LockProfThreshold)
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 62f6a1327d..5c86a81f93 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -250,6 +250,7 @@ Runtime::Runtime()
must_relocate_(false),
is_concurrent_gc_enabled_(true),
is_explicit_gc_disabled_(false),
+ is_eagerly_release_explicit_gc_disabled_(false),
image_dex2oat_enabled_(true),
default_stack_size_(0),
heap_(nullptr),
@@ -1504,6 +1505,8 @@ bool Runtime::Init(RuntimeArgumentMap&& runtime_options_in) {
is_zygote_ = runtime_options.Exists(Opt::Zygote);
is_primary_zygote_ = runtime_options.Exists(Opt::PrimaryZygote);
is_explicit_gc_disabled_ = runtime_options.Exists(Opt::DisableExplicitGC);
+ is_eagerly_release_explicit_gc_disabled_ =
+ runtime_options.Exists(Opt::DisableEagerlyReleaseExplicitGC);
image_dex2oat_enabled_ = runtime_options.GetOrDefault(Opt::ImageDex2Oat);
dump_native_stack_on_sig_quit_ = runtime_options.GetOrDefault(Opt::DumpNativeStackOnSigQuit);
allow_in_memory_compilation_ = runtime_options.Exists(Opt::AllowInMemoryCompilation);
diff --git a/runtime/runtime.h b/runtime/runtime.h
index fc8c050cf1..335ba546ab 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -217,6 +217,10 @@ class Runtime {
return is_explicit_gc_disabled_;
}
+ bool IsEagerlyReleaseExplicitGcDisabled() const {
+ return is_eagerly_release_explicit_gc_disabled_;
+ }
+
std::string GetCompilerExecutable() const;
const std::vector<std::string>& GetCompilerOptions() const {
@@ -1260,6 +1264,7 @@ class Runtime {
bool must_relocate_;
bool is_concurrent_gc_enabled_;
bool is_explicit_gc_disabled_;
+ bool is_eagerly_release_explicit_gc_disabled_;
bool image_dex2oat_enabled_;
std::string compiler_executable_;
diff --git a/runtime/runtime_options.def b/runtime/runtime_options.def
index b2fcf7df13..d4e074273f 100644
--- a/runtime/runtime_options.def
+++ b/runtime/runtime_options.def
@@ -117,6 +117,7 @@ RUNTIME_OPTIONS_KEY (Memory<1>, LargeObjectThreshold, gc::He
RUNTIME_OPTIONS_KEY (BackgroundGcOption, BackgroundGc)
RUNTIME_OPTIONS_KEY (Unit, DisableExplicitGC)
+RUNTIME_OPTIONS_KEY (Unit, DisableEagerlyReleaseExplicitGC)
RUNTIME_OPTIONS_KEY (Unit, NoSigChain)
RUNTIME_OPTIONS_KEY (Unit, ForceNativeBridge)
RUNTIME_OPTIONS_KEY (LogVerbosity, Verbose)
diff --git a/tools/art b/tools/art
index 662c4a0223..47724de9f9 100755
--- a/tools/art
+++ b/tools/art
@@ -330,9 +330,11 @@ ALLOW_DEFAULT_JDWP="no"
VERBOSE="no"
CLEAN_OAT_FILES="yes"
RUN_DEX2OAT="yes"
-# 'art' script is for benchmarking, so override default JIT thresholds that are
-# too conservative for benchmarking.
-EXTRA_OPTIONS=(-Xjitwarmupthreshold:4000 -Xjitthreshold:10000)
+# 'art' script is for benchmarking, so override:
+# - default JIT thresholds that are too conservative for benchmarking
+# - the eagerly releasing memory to the OS on explicit GC, which is more suited
+# for multi-apps execution than benchmarks.
+EXTRA_OPTIONS=(-Xjitwarmupthreshold:4000 -Xjitthreshold:10000 -XX:+DisableEagerlyReleaseExplicitGC)
DEX2OAT_FLAGS=()
DEX2OAT_CLASSPATH=()
GENERATE_APP_IMAGE="no"