diff --git a/src/replica/replica_stub.cpp b/src/replica/replica_stub.cpp index f741a85aa0..8a3d4b262f 100644 --- a/src/replica/replica_stub.cpp +++ b/src/replica/replica_stub.cpp @@ -89,6 +89,7 @@ replica_stub::replica_stub(replica_state_subscriber subscriber /*= nullptr*/, { #ifdef DSN_ENABLE_GPERF _release_tcmalloc_memory_command = nullptr; + _get_tcmalloc_status_command = nullptr; _max_reserved_memory_percentage_command = nullptr; #endif _replica_state_subscriber = subscriber; @@ -2203,6 +2204,16 @@ void replica_stub::register_ctrl_command() _release_tcmalloc_memory, "release-tcmalloc-memory", args); }); + _get_tcmalloc_status_command = ::dsn::command_manager::instance().register_command( + {"replica.get-tcmalloc-status"}, + "replica.get-tcmalloc-status", + "replica.get-tcmalloc-status - get status of tcmalloc", + [this](const std::vector &args) { + char buf[4096]; + MallocExtension::instance()->GetStats(buf, 4096); + return std::string(buf); + }); + _max_reserved_memory_percentage_command = dsn::command_manager::instance().register_command( {"replica.mem-release-max-reserved-percentage"}, "replica.mem-release-max-reserved-percentage [num | DEFAULT]", @@ -2384,6 +2395,7 @@ void replica_stub::close() UNREGISTER_VALID_HANDLER(_query_app_envs_command); #ifdef DSN_ENABLE_GPERF UNREGISTER_VALID_HANDLER(_release_tcmalloc_memory_command); + UNREGISTER_VALID_HANDLER(_get_tcmalloc_status_command); UNREGISTER_VALID_HANDLER(_max_reserved_memory_percentage_command); #endif UNREGISTER_VALID_HANDLER(_max_concurrent_bulk_load_downloading_count_command); @@ -2397,6 +2409,7 @@ void replica_stub::close() _query_app_envs_command = nullptr; #ifdef DSN_ENABLE_GPERF _release_tcmalloc_memory_command = nullptr; + _get_tcmalloc_status_command = nullptr; _max_reserved_memory_percentage_command = nullptr; #endif _max_concurrent_bulk_load_downloading_count_command = nullptr; diff --git a/src/replica/replica_stub.h b/src/replica/replica_stub.h index b0591dbbf5..f46b482240 100644 --- a/src/replica/replica_stub.h +++ b/src/replica/replica_stub.h @@ -363,6 +363,7 @@ class replica_stub : public serverlet, public ref_counter dsn_handle_t _query_app_envs_command; #ifdef DSN_ENABLE_GPERF dsn_handle_t _release_tcmalloc_memory_command; + dsn_handle_t _get_tcmalloc_status_command; dsn_handle_t _max_reserved_memory_percentage_command; #endif dsn_handle_t _max_concurrent_bulk_load_downloading_count_command;