Commit c4a5bd1e authored by Monty's avatar Monty

Added Myisam, Aria and InnoDB buffer pool to @@memory_used status variable

This makes it easier to see how much memory MariaDB server has allocated.
(For all memory allocations that goes through mysys)
parent e3b36b8f
......@@ -160,6 +160,7 @@ extern my_thread_id (*sf_malloc_dbug_id)(void);
typedef void (*MALLOC_SIZE_CB) (long long size, my_bool is_thread_specific);
extern void set_malloc_size_cb(MALLOC_SIZE_CB func);
extern MALLOC_SIZE_CB update_malloc_size;
/* defines when allocating data */
extern void *my_malloc(PSI_memory_key key, size_t size, myf MyFlags);
......
......@@ -398,6 +398,7 @@ uchar *my_large_malloc(size_t *size, myf my_flags)
if (ptr != NULL)
{
MEM_MAKE_DEFINED(ptr, *size);
update_malloc_size(*size, 0);
}
DBUG_RETURN(ptr);
......@@ -430,31 +431,36 @@ void my_large_free(void *ptr, size_t size)
{
my_error(EE_BADMEMORYRELEASE, MYF(ME_ERROR_LOG_ONLY), ptr, size, errno);
}
# if !__has_feature(memory_sanitizer)
#if !__has_feature(memory_sanitizer)
else
{
MEM_MAKE_ADDRESSABLE(ptr, size);
}
# endif
#endif
update_malloc_size(- (longlong) size, 0);
#elif defined(_WIN32)
/*
When RELEASE memory, the size parameter must be 0.
Do not use MEM_RELEASE with MEM_DECOMMIT.
*/
if (ptr && !VirtualFree(ptr, 0, MEM_RELEASE))
if (ptr)
{
if (!VirtualFree(ptr, 0, MEM_RELEASE))
{
my_error(EE_BADMEMORYRELEASE, MYF(ME_ERROR_LOG_ONLY), ptr, size,
GetLastError());
}
# if !__has_feature(memory_sanitizer)
update_malloc_size(- (longlong) size, 0);
}
#if !__has_feature(memory_sanitizer)
else
{
MEM_MAKE_ADDRESSABLE(ptr, size);
}
# endif
#endif /* memory_sanitizer */
#else
my_free_lock(ptr);
#endif
#endif /* HAVE_MMMAP */
DBUG_VOID_RETURN;
}
......@@ -32,7 +32,7 @@ struct st_mem_list
LIST *mem_list;
uchar *my_malloc_lock(uint size,myf MyFlags)
uchar *my_malloc_lock(size_t size, myf MyFlags)
{
int success;
uint pagesize=sysconf(_SC_PAGESIZE);
......@@ -70,6 +70,7 @@ uchar *my_malloc_lock(uint size,myf MyFlags)
mysql_mutex_lock(&THR_LOCK_malloc);
mem_list=list_add(mem_list,&element->list);
mysql_mutex_unlock(&THR_LOCK_malloc);
update_malloc_size((longlong) size, 0);
}
DBUG_RETURN(ptr);
}
......@@ -88,6 +89,7 @@ void my_free_lock(uchar *ptr)
{ /* Found locked mem */
(void) munlock((uchar*) ptr,element->size);
mem_list=list_delete(mem_list,list);
update_malloc_size(- (longlong) element->size, 0);
break;
}
}
......
......@@ -48,7 +48,7 @@ static void dummy(long long size __attribute__((unused)),
my_bool is_thread_specific __attribute__((unused)))
{}
static MALLOC_SIZE_CB update_malloc_size= dummy;
MALLOC_SIZE_CB update_malloc_size= dummy;
void set_malloc_size_cb(MALLOC_SIZE_CB func)
{
......
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