SELECT SUBSTRING_INDEX(event_name,'/',2) AS
code_area, FORMAT_BYTES(SUM(current_alloc))
AS current_alloc
FROM sys.x$memory_global_by_current_bytes
GROUP BY SUBSTRING_INDEX(event_name,'/',2)
ORDER BY SUM(current_alloc) DESC;
查询mysql事件使用的内存
SELECT*FROM sys.x$memory_global_by_current_bytes where event_name like'memory/performance%'ORDERBY current_avg_alloc DESCSELECT event_name, SUM(CAST(replace(current_alloc,'MiB','') asDECIMAL(10, 2)) ) FROM sys.memory_global_by_current_bytes WHERE current_alloc like'%MiB%'GROUPBY event_name ORDERBYSUM(CAST(replace(current_alloc,'MiB','') asDECIMAL(10, 2)) ) DESC ;
查询关键参数:
show variables like'key_buffer_size';
show variables like'query_cache_size';
show variables like'tmp_table_size';
show variables like'innodb_buffer_pool_size';
show variables like'innodb_additional_mem_pool_size';
show variables like'innodb_log_buffer_size';
show variables like'max_connections';
show variables like'sort_buffer_size';
show variables like'read_buffer_size';
show variables like'read_rnd_buffer_size';
show variables like'join_buffer_size';
show variables like'thread_stack';
show variables like'binlog_cache_size';
show variables like'performance_schema';
解决办法:
1、关闭performance_schema
在配置文件中新增
performance_schema=OFF
关闭性能监测,重启后观察
2、glibc的内存管理器自身缺陷导致
gdb --batch --pid `pidof mysqld` --ex 'call malloc_trim(0)'
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
45305 mysql 20028.4g 5.2g 8288 S 2.717.064:56.82 mysqld
3、使用jemalloc解决此问题
wget https://github.com/jemalloc/jemalloc/releases/download/4.4.0/jemalloc-4.4.0.tar.bz2
tar xjf jemalloc-4.4.0.tar.bz2
cd jemalloc-4.4.0
./configure
make && make install
find / -name "*jemalloc.so*"export LD_PRELOAD=/usr/local/lib/libjemalloc.so
lsof -n | grep jemalloc
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 【.NET】调用本地 Deepseek 模型
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
2020-06-16 SQL Server:SQL Like 通配符特殊用法:Escape
2018-06-16 gdb调试