Commit 9a3cbc05 authored by David CARLIER's avatar David CARLIER Committed by Daniel Black

mysqld: print status display subset of memory usage.

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
parent 6c3e860c
......@@ -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 "")
......
......@@ -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
......
......@@ -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)
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment