diff --git a/src/memory/global_memory_control.cpp b/src/memory/global_memory_control.cpp
index 43a34f241..b378bd6fb 100644
--- a/src/memory/global_memory_control.cpp
+++ b/src/memory/global_memory_control.cpp
@@ -224,18 +224,19 @@ void SetHooks() {
       LOG_FATAL("Error setting custom hooks for jemalloc arena {}", i);
     }
   }
+  auto last_arena = n_arenas;
   // For oversize arena, no need to read hooks, it will be intialized
   // with arena, just set our custom hooks
-  std::string func_name = "arena." + std::to_string(8) + ".extent_hooks";
+  std::string func_name = "arena." + std::to_string(last_arena) + ".extent_hooks";
 
   if (err) {
-    LOG_FATAL("Error setting jemalloc hooks for jemalloc arena {}", 8);
+    LOG_FATAL("Error setting jemalloc hooks for jemalloc arena {}", last_arena);
   }
 
   err = mallctl(func_name.c_str(), nullptr, nullptr, &new_hooks, sizeof(new_hooks));
 
   if (err) {
-    LOG_FATAL("Error setting custom hooks for jemalloc arena {}", 8);
+    LOG_FATAL("Error setting custom hooks for jemalloc oversize threshold arena {}", last_arena);
   }
 
 #endif