Optimize the removal of garbage collected references to avoid memory leaks
mAllResourceReferences collects weak references to a resource when it is constructed, which is used to update the resource path of the library when loading webview. Currently, its garbage collected references(mAllResourceReferencesQueue) only cleaned up when ResourcesManager#redirectAllResourcesToNewImplLocked is executed, which means that if the application does not rely on webview, then cleanup cannot be performed. Therefore, we need to clean up the mAllResourceReferencesQueue once when creating a new Resource and preparing to add its weak reference to mAllResourceReferences. Bug: 363887630 Test: Create multiple new resources in app and observe mAllResourceReferencesQueue Signed-off-by:zhangshuai10 <zhangshuai10@xiaomi.corp-partner.google.com> (cherry picked from https://partner-android-review.googlesource.com/q/commit:d64e23dcff6acee2b8dd57a047389172fe95054e) Merged-In: Ide10752f2dce86ff9b7d16335e625ae1919255f3 Change-Id: Ide10752f2dce86ff9b7d16335e625ae1919255f3
Loading
Please register or sign in to comment