diff options
author | David CARLIER <devnexen@gmail.com> | 2021-04-13 20:23:46 +0100 |
---|---|---|
committer | Daniel Black <daniel@mariadb.org> | 2021-04-14 19:21:35 +1000 |
commit | 9a3cbc05415dd862852dffbd368527319107f460 (patch) | |
tree | 8f9556308a6f0cd65b7bac4bf7193c6b37268f92 | |
parent | 6c3e860cbf36831c118f6ea183acbbeb3c889bed (diff) | |
download | mariadb-git-9a3cbc05415dd862852dffbd368527319107f460.tar.gz |
mysqld: print status display subset of memory usage.bb-10.5-danielblack-pr1803-darwin-debug-memory
leveling up to some degree with linux's mallinfo* api for
the memory usage display with debug build with malloc_zone
Darwin api.
Closes: #1803
-rw-r--r-- | cmake/os/WindowsCache.cmake | 1 | ||||
-rw-r--r-- | config.h.cmake | 1 | ||||
-rw-r--r-- | configure.cmake | 1 | ||||
-rw-r--r-- | sql/sql_test.cc | 16 |
4 files changed, 19 insertions, 0 deletions
diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake index 0f7e3c9bf16..e9b9e187722 100644 --- a/cmake/os/WindowsCache.cmake +++ b/cmake/os/WindowsCache.cmake @@ -92,6 +92,7 @@ SET(HAVE_MADVISE CACHE INTERNAL "") SET(HAVE_MALLINFO CACHE INTERNAL "") SET(HAVE_MALLINFO2 CACHE INTERNAL "") SET(HAVE_MALLOC_H 1 CACHE INTERNAL "") +SET(HAVE_MALLOC_ZONE CACHE INTERNAL "") SET(HAVE_MEMALIGN CACHE INTERNAL "") SET(HAVE_MEMCPY 1 CACHE INTERNAL "") SET(HAVE_MEMMOVE 1 CACHE INTERNAL "") diff --git a/config.h.cmake b/config.h.cmake index 2af94f96d9a..d7eb8f7c9d3 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -170,6 +170,7 @@ #cmakedefine HAVE_DECL_MHA_MAPSIZE_VA 1 #cmakedefine HAVE_MALLINFO 1 #cmakedefine HAVE_MALLINFO2 1 +#cmakedefine HAVE_MALLOC_ZONE 1 #cmakedefine HAVE_MEMCPY 1 #cmakedefine HAVE_MEMMOVE 1 #cmakedefine HAVE_MKSTEMP 1 diff --git a/configure.cmake b/configure.cmake index a90ba810b40..8cff10a24ac 100644 --- a/configure.cmake +++ b/configure.cmake @@ -364,6 +364,7 @@ CHECK_FUNCTION_EXISTS (lstat HAVE_LSTAT) CHECK_FUNCTION_EXISTS (madvise HAVE_MADVISE) CHECK_FUNCTION_EXISTS (mallinfo HAVE_MALLINFO) CHECK_FUNCTION_EXISTS (mallinfo2 HAVE_MALLINFO2) +CHECK_FUNCTION_EXISTS (malloc_zone_statistics HAVE_MALLOC_ZONE) CHECK_FUNCTION_EXISTS (memcpy HAVE_MEMCPY) CHECK_FUNCTION_EXISTS (memmove HAVE_MEMMOVE) CHECK_FUNCTION_EXISTS (mkstemp HAVE_MKSTEMP) diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 36e4fedf835..6c1e5a2a578 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -33,6 +33,8 @@ #include <malloc.h> #elif defined(HAVE_MALLINFO) && defined(HAVE_SYS_MALLOC_H) #include <sys/malloc.h> +#elif defined(HAVE_MALLOC_ZONE) +#include <malloc/malloc.h> #endif #ifdef HAVE_EVENT_SCHEDULER @@ -653,6 +655,20 @@ Memory allocated by threads: %s\n", llstr(tmp.global_memory_used, llbuff[8]), llstr(tmp.local_memory_used, llbuff[9])); +#elif defined(HAVE_MALLOC_ZONE) + malloc_statistics_t info; + char llbuff[4][22]; + + malloc_zone_statistics(nullptr, &info); + printf("\nMemory status:\n\ +Total allocated space: %s\n\ +Total free space: %s\n\ +Global memory allocated by server: %s\n\ +Memory allocated by threads: %s\n", + llstr(info.size_allocated, llbuff[0]), + llstr((info.size_allocated - info.size_in_use), llbuff[1]), + llstr(tmp.global_memory_used, llbuff[2]), + llstr(tmp.local_memory_used, llbuff[3])); #endif #ifdef HAVE_EVENT_SCHEDULER |