5.7 of Performance_schema already have the ability to monitor the memory usage of MySQL, for this is to be achieved through the instrument, because the memory this piece does not have a corresponding consumer so long as
Well, it's okay to configure instrument.
1. Example:
/etc/my.cnf
[Mysqld]datadir =/usr/local/mysql/databasedir =/usr/local/mysqlperformance_schema_instrument = ' Memory%=counted '
Select Event_name,current_alloc from sys.memory_global_by_current_bytes limit 10;+--------------------------------- --------------------------------------------+---------------+| Event_Name | Current_alloc |+-----------------------------------------------------------------------------+---------------+| Memory/innodb/buf_buf_pool | 131.06 MiB | | Memory/innodb/log0log | 32.01 MiB | | Memory/performance_schema/events_statements_history_long | 13.66 MiB | | Memory/performance_schema/events_statements_history_long.sqltext | 9.77 MiB | | Memory/performance_schema/events_statements_history_long.tokens | 9.77 MiB | | Memory/performance_schema/events_statements_summary_by_digest.tokens | 9.77 MiB | | Memory/performance_schema/table_handles | 9.06 MiB | | Memory/performance_schema/events_statements_summary_by_thread_by_event_name | 8.67 MiB | | Memory/mysys/key_cache | 8.00 MiB | | Memory/performance_schema/memory_summary_by_thread_by_event_name | 5.62 MiB |+-----------------------------------------------------------------------------+---------------+
MySQL 5.7 Memory usage monitoring