diff --git a/src/Common/MemoryTracker.cpp b/src/Common/MemoryTracker.cpp index 50ddcb5a9eb..ad8647d6da4 100644 --- a/src/Common/MemoryTracker.cpp +++ b/src/Common/MemoryTracker.cpp @@ -15,7 +15,7 @@ #ifdef MEMORY_TRACKER_DEBUG_CHECKS -thread_local bool _memory_tracker_always_throw_logical_error_on_allocation = false; +thread_local bool memory_tracker_always_throw_logical_error_on_allocation = false; #endif namespace @@ -173,9 +173,9 @@ void MemoryTracker::allocImpl(Int64 size, bool throw_if_memory_exceeded) } #ifdef MEMORY_TRACKER_DEBUG_CHECKS - if (unlikely(_memory_tracker_always_throw_logical_error_on_allocation)) + if (unlikely(memory_tracker_always_throw_logical_error_on_allocation)) { - _memory_tracker_always_throw_logical_error_on_allocation = false; + memory_tracker_always_throw_logical_error_on_allocation = false; throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "Memory tracker: allocations not allowed."); } #endif diff --git a/src/Common/MemoryTracker.h b/src/Common/MemoryTracker.h index d87e922ef09..adba0b42f57 100644 --- a/src/Common/MemoryTracker.h +++ b/src/Common/MemoryTracker.h @@ -15,11 +15,11 @@ /// DENY_ALLOCATIONS_IN_SCOPE in the inner scope. In Release builds these macros do nothing. #ifdef MEMORY_TRACKER_DEBUG_CHECKS #include -extern thread_local bool _memory_tracker_always_throw_logical_error_on_allocation; +extern thread_local bool memory_tracker_always_throw_logical_error_on_allocation; #define ALLOCATIONS_IN_SCOPE_IMPL_CONCAT(n, val) \ - bool _allocations_flag_prev_val##n = _memory_tracker_always_throw_logical_error_on_allocation; \ - _memory_tracker_always_throw_logical_error_on_allocation = val; \ - SCOPE_EXIT({ _memory_tracker_always_throw_logical_error_on_allocation = _allocations_flag_prev_val##n; }) + bool _allocations_flag_prev_val##n = memory_tracker_always_throw_logical_error_on_allocation; \ + memory_tracker_always_throw_logical_error_on_allocation = val; \ + SCOPE_EXIT({ memory_tracker_always_throw_logical_error_on_allocation = _allocations_flag_prev_val##n; }) #define ALLOCATIONS_IN_SCOPE_IMPL(n, val) ALLOCATIONS_IN_SCOPE_IMPL_CONCAT(n, val) #define DENY_ALLOCATIONS_IN_SCOPE ALLOCATIONS_IN_SCOPE_IMPL(__LINE__, true) #define ALLOW_ALLOCATIONS_IN_SCOPE ALLOCATIONS_IN_SCOPE_IMPL(__LINE__, false)