This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new c3f89c2c1f2 branch-4.0: [bugfix](jvmmetrics) some object is nullptr if 
java support is not enabled #57953 (#57970)
c3f89c2c1f2 is described below

commit c3f89c2c1f22cb27ecaeb5eaa2ef11b9a0bb02db
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Nov 13 14:39:31 2025 +0800

    branch-4.0: [bugfix](jvmmetrics) some object is nullptr if java support is 
not enabled #57953 (#57970)
    
    Cherry-picked from #57953
    
    Co-authored-by: yiguolei <[email protected]>
---
 be/src/runtime/memory/memory_profile.cpp | 15 ++++++++++-----
 be/src/util/jvm_metrics.cpp              |  4 ++++
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/be/src/runtime/memory/memory_profile.cpp 
b/be/src/runtime/memory/memory_profile.cpp
index 42898a9f50a..1549cc02fbb 100644
--- a/be/src/runtime/memory/memory_profile.cpp
+++ b/be/src/runtime/memory/memory_profile.cpp
@@ -261,11 +261,16 @@ void MemoryProfile::refresh_memory_overview_profile() {
     COUNTER_SET(_jemalloc_memory_usage_counter,
                 _jemalloc_cache_usage_counter->current_value() +
                         _jemalloc_metadata_usage_counter->current_value());
-    DorisMetrics::instance()->jvm_metrics()->update();
-    int64_t jvm_heap_bytes =
-            
DorisMetrics::instance()->jvm_metrics()->jvm_heap_size_bytes_committed->value();
-    int64_t jvm_non_heap_bytes =
-            
DorisMetrics::instance()->jvm_metrics()->jvm_non_heap_size_bytes_committed->value();
+    int64_t jvm_heap_bytes = 0;
+    int64_t jvm_non_heap_bytes = 0;
+    // JvmMetrics only inited when enable_java_support == true, or it is 
nullptr
+    if (DorisMetrics::instance()->jvm_metrics() != nullptr) {
+        DorisMetrics::instance()->jvm_metrics()->update();
+        jvm_heap_bytes =
+                
DorisMetrics::instance()->jvm_metrics()->jvm_heap_size_bytes_committed->value();
+        jvm_non_heap_bytes =
+                
DorisMetrics::instance()->jvm_metrics()->jvm_non_heap_size_bytes_committed->value();
+    }
 
     all_tracked_mem_sum += jvm_heap_bytes + jvm_non_heap_bytes;
     COUNTER_SET(_jvm_heap_memory_usage_counter, jvm_heap_bytes);
diff --git a/be/src/util/jvm_metrics.cpp b/be/src/util/jvm_metrics.cpp
index b1089ef4136..58dc3453eae 100644
--- a/be/src/util/jvm_metrics.cpp
+++ b/be/src/util/jvm_metrics.cpp
@@ -138,6 +138,10 @@ JvmMetrics::JvmMetrics(MetricRegistry* registry, JNIEnv* 
env) {
 }
 
 void JvmMetrics::update() {
+    // If enable_jvm_monitor is false, the jvm stats object is not 
initialized. call jvm_stats.refresh() may core.
+    if (!doris::config::enable_jvm_monitor) {
+        return;
+    }
     static long fail_count = 0;
     try {
         Status st = _jvm_stats.refresh(this);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to