ICU-22761 Optimize get value of LocaleObjectCache #2984
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When invoking get(K key) method of LocaleObjectCache, it may be blocked for a long time, looping in lines 45 and 53, because after the referent of SoftReference is set to NULL, it may take a long time to add SoftReference to its ReferenceQueue if GC is slowly.
For example, in the Concurrent Copying GC in Android Art virtual machine, the referent in SoftReference is set to null during the copying phase, while the SoftReference is added to its ReferenceQueue in the ReferenceQueueDaemon thread after GC, which experiences a long time in between
In fact, we have found many examples of blocking for more than 10s on some Android devices
Checklist