diff --git a/include/dsn/perf_counter/perf_counter_wrapper.h b/include/dsn/perf_counter/perf_counter_wrapper.h index 51ef5a08b6..e834995887 100644 --- a/include/dsn/perf_counter/perf_counter_wrapper.h +++ b/include/dsn/perf_counter/perf_counter_wrapper.h @@ -63,7 +63,7 @@ class perf_counter_wrapper perf_counter_wrapper &operator=(perf_counter_wrapper &other) = delete; perf_counter_wrapper &operator=(perf_counter_wrapper &&other) = delete; - ~perf_counter_wrapper() { clear(); } + ~perf_counter_wrapper() {} // clear the real perf-counter object. // call this function if you want free the counter before the wrapper's destructor is called @@ -103,6 +103,7 @@ class perf_counter_wrapper dsn::perf_counter *get() const { return _counter; } dsn::perf_counter *operator->() const { return _counter; } + private: // use raw pointer to make the class object small, so it can be accessed quickly dsn::perf_counter *_counter; diff --git a/src/perf_counter/perf_counters.cpp b/src/perf_counter/perf_counters.cpp index ef89a84267..732cfd4b01 100644 --- a/src/perf_counter/perf_counters.cpp +++ b/src/perf_counter/perf_counters.cpp @@ -91,6 +91,7 @@ perf_counters::perf_counters() perf_counters::~perf_counters() { + _counters.clear(); UNREGISTER_VALID_HANDLER(_perf_counters_cmd); UNREGISTER_VALID_HANDLER(_perf_counters_by_substr_cmd); UNREGISTER_VALID_HANDLER(_perf_counters_by_prefix_cmd);