gavinchou commented on code in PR #34354: URL: https://github.com/apache/doris/pull/34354#discussion_r1587032527
########## be/src/util/jni-util.cpp: ########## @@ -204,6 +205,22 @@ Status JniLocalFrame::push(JNIEnv* env, int max_local_ref) { return Status::OK(); } +void JniUtil::parse_max_heap_memory_size_from_jvm(JNIEnv* env) { + jclass cls = env->FindClass("java/lang/management/MemoryPoolMXBean"); + jmethodID mid = env->GetStaticMethodID( + cls, "getPlatformMXBean", + "(Ljavax/management/MBeanServerConnection;)Ljava/lang/management/MemoryPoolMXBean;"); + jobject bean = env->CallStaticObjectMethod(cls, mid, NULL); + + jclass beanClass = env->GetObjectClass(bean); + mid = env->GetMethodID(beanClass, "getUsage", "()Ljava/lang/management/MemoryUsage;"); + jobject mu = env->CallObjectMethod(bean, mid); + + jclass muClass = env->GetObjectClass(mu); + jfieldID max = env->GetFieldID(muClass, "max", "J"); + max_jvm_heap_memory_size_ = env->GetLongField(mu, max); Review Comment: Is there any chance that the left-hand-side value is nullpointer? Do we have to consider that situation? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org