Skip to content

Commit

Permalink
disable ICU cache pinning for exec spawning
Browse files Browse the repository at this point in the history
  • Loading branch information
thestinger committed Jun 1, 2020
1 parent 29f28b5 commit 13a992c
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions dalvik/src/main/java/dalvik/system/ZygoteHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@ private ZygoteHooks() {
*/
@libcore.api.CorePlatformApi
public static void onBeginPreload(boolean fullPreload) {
// Pin ICU data in memory from this point that would normally be held by soft references.
// Without this, any references created immediately below or during class preloading
// would be collected when the Zygote GC runs in gcAndFinalize().
CacheValue.setStrength(CacheValue.Strength.STRONG);

// Explicitly exercise code to cache data apps are likely to need.
ULocale[] localesToPin = { ULocale.ROOT, ULocale.US, ULocale.getDefault() };
for (ULocale uLocale : localesToPin) {
new DecimalFormatSymbols(uLocale);
if (fullPreload) {
// Pin ICU data in memory from this point that would normally be held by soft references.
// Without this, any references created immediately below or during class preloading
// would be collected when the Zygote GC runs in gcAndFinalize().
CacheValue.setStrength(CacheValue.Strength.STRONG);

// Explicitly exercise code to cache data apps are likely to need.
ULocale[] localesToPin = { ULocale.ROOT, ULocale.US, ULocale.getDefault() };
for (ULocale uLocale : localesToPin) {
new DecimalFormatSymbols(uLocale);
}
}
}

Expand All @@ -65,8 +67,10 @@ public static void onBeginPreload(boolean fullPreload) {
*/
@libcore.api.CorePlatformApi
public static void onEndPreload(boolean fullPreload) {
// All cache references created by ICU from this point will be soft.
CacheValue.setStrength(CacheValue.Strength.SOFT);
if (fullPreload) {
// All cache references created by ICU from this point will be soft.
CacheValue.setStrength(CacheValue.Strength.SOFT);
}
}

/**
Expand Down

0 comments on commit 13a992c

Please sign in to comment.