From 46f061b500457bf934a976b7e09b3bae8c3cbdb0 Mon Sep 17 00:00:00 2001 From: Chungmin Lee Date: Fri, 30 Jan 2026 16:44:14 -0800 Subject: [PATCH] [Core] Fix protobuf memory leak in JNI_OnUnload Add google::protobuf::ShutdownProtobufLibrary() call to properly clean up protobuf's static internal data structures when the JNI library is unloaded. This fixes memory leak reports from LeakSanitizer. Closes #11531 --- cpp/core/jni/JniWrapper.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpp/core/jni/JniWrapper.cc b/cpp/core/jni/JniWrapper.cc index adada15f91df..3c5d3ca2815a 100644 --- a/cpp/core/jni/JniWrapper.cc +++ b/cpp/core/jni/JniWrapper.cc @@ -26,6 +26,7 @@ #include "jni/JniError.h" #include +#include #include #include #include "memory/AllocationListener.h" @@ -304,6 +305,8 @@ void JNI_OnUnload(JavaVM* vm, void* reserved) { getJniErrorState()->close(); getJniCommonState()->close(); + + google::protobuf::ShutdownProtobufLibrary(); } JNIEXPORT jlong JNICALL Java_org_apache_gluten_runtime_RuntimeJniWrapper_createRuntime( // NOLINT