1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

Final fixes for Memory_used

- Change some static variables to dynamic to ensure that we don't do any memory
  allocations before server starts or stops
- Print more memory information on SIGHUP. Fixed output.
- Write out if memory was lost if run with --debug-at-exit
- Fixed wrong #ifdef in sql_cache.cc
This commit is contained in:
Monty
2016-04-28 17:15:38 +03:00
parent 32d3d9f7df
commit 636bb59034
15 changed files with 78 additions and 48 deletions

View File

@ -54,7 +54,7 @@ static const char *lock_descriptions[] =
};
#ifndef DBUG_OFF
#ifdef EXTRA_DEBUG
void
print_where(COND *cond,const char *info, enum_query_type query_type)
@ -559,16 +559,19 @@ C_MODE_END
void mysql_print_status()
{
char current_dir[FN_REFLEN];
char llbuff[10][22];
STATUS_VAR tmp;
uint count;
calc_sum_of_all_status(&tmp);
count= calc_sum_of_all_status(&tmp);
printf("\nStatus information:\n\n");
(void) my_getwd(current_dir, sizeof(current_dir),MYF(0));
printf("Current dir: %s\n", current_dir);
printf("Running threads: %d Stack size: %ld\n", thread_count,
printf("Running threads: %d Cached threads: %lu Stack size: %ld\n",
count, cached_thread_count,
(long) my_thread_stack_size);
#ifdef EXTRA_DEBUG
thr_print_locks(); // Write some debug info
#ifndef DBUG_OFF
print_cached_tables();
#endif
/* Print key cache status */
@ -614,28 +617,33 @@ Next alarm time: %lu\n",
#ifdef HAVE_MALLINFO
struct mallinfo info= mallinfo();
printf("\nMemory status:\n\
Non-mmapped space allocated from system: %d\n\
Number of free chunks: %d\n\
Number of fastbin blocks: %d\n\
Number of mmapped regions: %d\n\
Space in mmapped regions: %d\n\
Maximum total allocated space: %d\n\
Space available in freed fastbin blocks: %d\n\
Total allocated space: %d\n\
Total free space: %d\n\
Top-most, releasable space: %d\n\
Estimated memory (with thread stack): %ld\n",
(int) info.arena ,
(int) info.ordblks,
(int) info.smblks,
(int) info.hblks,
(int) info.hblkhd,
(int) info.usmblks,
(int) info.fsmblks,
(int) info.uordblks,
(int) info.fordblks,
(int) info.keepcost,
(long) (thread_count * my_thread_stack_size + info.hblkhd + info.arena));
Non-mmapped space allocated from system: %s\n\
Number of free chunks: %lu\n\
Number of fastbin blocks: %lu\n\
Number of mmapped regions: %lu\n\
Space in mmapped regions: %s\n\
Maximum total allocated space: %s\n\
Space available in freed fastbin blocks: %s\n\
Total allocated space: %s\n\
Total free space: %s\n\
Top-most, releasable space: %s\n\
Estimated memory (with thread stack): %s\n\
Global memory allocated by server: %s\n\
Memory allocated by threads: %s\n",
llstr(info.arena, llbuff[0]),
(ulong) info.ordblks,
(ulong) info.smblks,
(ulong) info.hblks,
llstr(info.hblkhd, llbuff[1]),
llstr(info.usmblks, llbuff[2]),
llstr(info.fsmblks, llbuff[3]),
llstr(info.uordblks, llbuff[4]),
llstr(info.fordblks, llbuff[5]),
llstr(info.keepcost, llbuff[6]),
llstr((count + cached_thread_count)* my_thread_stack_size + info.hblkhd + info.arena, llbuff[7]),
llstr(tmp.global_memory_used, llbuff[8]),
llstr(tmp.local_memory_used, llbuff[9]));
#endif
#ifdef HAVE_EVENT_SCHEDULER