Looks like thd_local never gets released
mysql> SELECT event_name, sys.format_bytes(SUM(current_alloc)) AS current_alloc FROM sys.x$memory_global_by_current_bytes WHERE event_name like "%audit%" GROUP BY event_name ORDER BY SUM(current_alloc) DESC; +------------------------------------------+---------------+ | event_name | current_alloc | +------------------------------------------+---------------+ | memory/audit_log/audit_log_thd_local | 932.47 KiB | | memory/audit_log/audit_log_query_stack | 211.12 KiB | | memory/audit_log/audit_log_logger_handle | 712 bytes | | memory/audit_log/audit_log_commands | 640 bytes | | memory/audit_log/audit_log_databases | 640 bytes | | memory/audit_log/audit_log_accounts | 640 bytes | | memory/audit_log/audit_log_handler | 88 bytes | +------------------------------------------+---------------+ 7 rows in set (0.01 sec)
and few minutes later
mysql> SELECT event_name, sys.format_bytes(SUM(current_alloc)) AS current_alloc FROM sys.x$memory_global_by_current_bytes WHERE event_name like "%audit%" GROUP BY event_name ORDER BY SUM(current_alloc) DESC; +------------------------------------------+---------------+ | event_name | current_alloc | +------------------------------------------+---------------+ | memory/audit_log/audit_log_thd_local | 2.45 MiB | | memory/audit_log/audit_log_query_stack | 567.84 KiB | | memory/audit_log/audit_log_logger_handle | 712 bytes | | memory/audit_log/audit_log_commands | 640 bytes | | memory/audit_log/audit_log_databases | 640 bytes | | memory/audit_log/audit_log_accounts | 640 bytes | | memory/audit_log/audit_log_handler | 88 bytes | +------------------------------------------+---------------+ 7 rows in set (0.01 sec)
dynamic_variables_allocs is NULL:
* thread #26: tid = 0x2d4922, 0x000000010a5c50c3 mysqld`plugin_var_memalloc_free(vars=0x00007f87721509e0) + 35 at sql_plugin.cc:3322, stop reason = breakpoint 2.1 frame #0: 0x000000010a5c50c3 mysqld`plugin_var_memalloc_free(vars=0x00007f87721509e0) + 35 at sql_plugin.cc:3322 3319 static void plugin_var_memalloc_free(struct system_variables *vars) 3320 { 3321 LIST *next, *root; -> 3322 DBUG_ENTER("plugin_var_memalloc_free"); 3323 for (root= vars->dynamic_variables_allocs; root; root= next) 3324 { 3325 next= root->next; (lldb) p vars->dynamic_variables_allocs (LIST *) $0 = 0x0000000000000000
variables added to that list in `plugin_var_memalloc_session_update` if `value` is not NULL, but it is NULL... looking further
* thread #26: tid = 0x2d4922, 0x000000010a5c32c3 mysqld`plugin_var_memalloc_session_update(thd=0x00007f87718a1c00, var=0x0000000000000000, dest=0x00007f87734b8580, value=0x0000000000000000) + 51 at sql_plugin.cc:3276, stop reason = breakpoint 3.1 frame #0: 0x000000010a5c32c3 mysqld`plugin_var_memalloc_session_update(thd=0x00007f87718a1c00, var=0x0000000000000000, dest=0x00007f87734b8580, value=0x0000000000000000) + 51 at sql_plugin.cc:3276 3273 char **dest, const char *value) 3274 3275 { -> 3276 LIST *old_element= NULL; 3277 struct system_variables *vars= &thd->variables; 3278 DBUG_ENTER("plugin_var_memalloc_session_update");
Looks like thd_local never gets released
mysql> SELECT event_name, sys.format_ bytes(SUM( current_ alloc)) AS current_alloc FROM sys.x$memory_ global_ by_current_ bytes WHERE event_name like "%audit%" GROUP BY event_name ORDER BY SUM(current_alloc) DESC; ------- ------- ------- ------- ------- -+----- ------- ---+ ------- ------- ------- ------- ------- -+----- ------- ---+ audit_log/ audit_log_ thd_local | 932.47 KiB | audit_log/ audit_log_ query_stack | 211.12 KiB | audit_log/ audit_log_ logger_ handle | 712 bytes | audit_log/ audit_log_ commands | 640 bytes | audit_log/ audit_log_ databases | 640 bytes | audit_log/ audit_log_ accounts | 640 bytes | audit_log/ audit_log_ handler | 88 bytes | ------- ------- ------- ------- ------- -+----- ------- ---+
+------
| event_name | current_alloc |
+------
| memory/
| memory/
| memory/
| memory/
| memory/
| memory/
| memory/
+------
7 rows in set (0.01 sec)
and few minutes later
mysql> SELECT event_name, sys.format_ bytes(SUM( current_ alloc)) AS current_alloc FROM sys.x$memory_ global_ by_current_ bytes WHERE event_name like "%audit%" GROUP BY event_name ORDER BY SUM(current_alloc) DESC; ------- ------- ------- ------- ------- -+----- ------- ---+ ------- ------- ------- ------- ------- -+----- ------- ---+ audit_log/ audit_log_ thd_local | 2.45 MiB | audit_log/ audit_log_ query_stack | 567.84 KiB | audit_log/ audit_log_ logger_ handle | 712 bytes | audit_log/ audit_log_ commands | 640 bytes | audit_log/ audit_log_ databases | 640 bytes | audit_log/ audit_log_ accounts | 640 bytes | audit_log/ audit_log_ handler | 88 bytes | ------- ------- ------- ------- ------- -+----- ------- ---+
+------
| event_name | current_alloc |
+------
| memory/
| memory/
| memory/
| memory/
| memory/
| memory/
| memory/
+------
7 rows in set (0.01 sec)
dynamic_ variables_ allocs is NULL:
* thread #26: tid = 0x2d4922, 0x000000010a5c50c3 mysqld` plugin_ var_memalloc_ free(vars= 0x00007f8772150 9e0) + 35 at sql_plugin.cc:3322, stop reason = breakpoint 2.1 plugin_ var_memalloc_ free(vars= 0x00007f8772150 9e0) + 35 at sql_plugin.cc:3322 var_memalloc_ free(struct system_variables *vars) "plugin_ var_memalloc_ free"); variables_ allocs; root; root= next) variables_ allocs
frame #0: 0x000000010a5c50c3 mysqld`
3319 static void plugin_
3320 {
3321 LIST *next, *root;
-> 3322 DBUG_ENTER(
3323 for (root= vars->dynamic_
3324 {
3325 next= root->next;
(lldb) p vars->dynamic_
(LIST *) $0 = 0x0000000000000000
variables added to that list in `plugin_ var_memalloc_ session_ update` if `value` is not NULL, but it is NULL... looking further
* thread #26: tid = 0x2d4922, 0x000000010a5c32c3 mysqld` plugin_ var_memalloc_ session_ update( thd=0x00007f877 18a1c00, var=0x000000000 0000000, dest=0x00007f87 734b8580, value=0x0000000 000000000) + 51 at sql_plugin.cc:3276, stop reason = breakpoint 3.1 plugin_ var_memalloc_ session_ update( thd=0x00007f877 18a1c00, var=0x000000000 0000000, dest=0x00007f87 734b8580, value=0x0000000 000000000) + 51 at sql_plugin.cc:3276 "plugin_ var_memalloc_ session_ update" );
frame #0: 0x000000010a5c32c3 mysqld`
3273 char **dest, const char *value)
3274
3275 {
-> 3276 LIST *old_element= NULL;
3277 struct system_variables *vars= &thd->variables;
3278 DBUG_ENTER(