From acb46e4ce68e3308ef00f70982fc018ccbb02a5a Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Mon, 8 Jan 2024 11:10:18 -0800 Subject: Release VintfObject memory after compat check at boot time. After compatibility check at boot time, the VintfObject is usually no longer needed. Hence, at boot time, we actively release the VintfObject object after compatibility check by not using the shared instance in the first place. Test: TH Bug: 270169217 Change-Id: I9b3383cd52fa67eb18dd5837f96caf2b0eab2ce5 --- core/jni/android_os_VintfObject.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/jni/android_os_VintfObject.cpp b/core/jni/android_os_VintfObject.cpp index b6517117ca62..a5b2f65eafc7 100644 --- a/core/jni/android_os_VintfObject.cpp +++ b/core/jni/android_os_VintfObject.cpp @@ -96,8 +96,11 @@ static jobjectArray android_os_VintfObject_report(JNIEnv* env, jclass) static jint android_os_VintfObject_verifyBuildAtBoot(JNIEnv* env, jclass) { std::string error; + // Use temporary VintfObject, not the shared instance, to release memory + // after check. int32_t status = - VintfObject::GetInstance() + VintfObject::Builder() + .build() ->checkCompatibility(&error, ENABLE_ALL_CHECKS.disableAvb().disableKernel()); if (status) LOG(WARNING) << "VintfObject.verifyBuildAtBoot() returns " << status << ": " << error; -- cgit v1.2.3-59-g8ed1b