Bug #116555 RAM usage of centos7 is very high but can't control where it comes from
Submitted: 5 Nov 2024 11:02 Modified: 5 Nov 2024 11:49
Reporter: thi dang van Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Memcached Severity:S5 (Performance)
Version:8.0.31 OS:CentOS (7)
Assigned to: CPU Architecture:x86

[5 Nov 2024 11:02] thi dang van
Description:
I'm having a problem where the operating system's RAM usage is very high: about 95%->98% (about 30gb). I have looked at all the MySQL RAM monitors (https://dev.mysql.com/doc/refman/8.4/en/monitor-mysql-memory-use.html), and enabled all relevant flags count memory in performance_schema.setup_instruments table. And I see the total amount of RAM of all rows in the sys.x$memory_global_by_current_bytes table is only 19GB.
So where does the wasted 11GB of RAM go? Thanks to the experts, please suggest me how to reduce this amount of RAM. Does the free version of MySQL have this problem? If I upgrade to the Enterprise version, will it solve the problem? because I see Enterprise has a thread pool?

How to repeat:
Environment:

+Centos 7 (7 core CPU, 32 GB ram).
+MySQL version 8.0.31 (community server -GPL).

+My configuration param: 

innodb_buffer_pool_size: 8.19 GB
innodb_redo_log_capacity:100 MB
max_allowed_packet: 64 MB
innodb_log_buffer_size:16 MB
thread_stack:1 MB
join_buffer_size:250 kB
read_rnd_buffer_size:250 kB
sort_buffer_size:250 kB
read_buffer_size: 125 kB
net_buffer_length: 15.6 kB
max_digest_length: 977B
maxconection: 4000
wait_timeout:300
interactive_timeout:300

+Workload: My server has about 350 databases, with an average of threads_connected recorded (600->1200).
[5 Nov 2024 11:49] MySQL Verification Team
Hi Mr. van,

Thank you for your bug report.

However, what you are reporting is not MySQL bug.

It is a feature of the Linux operating system, that it leaves all memory attached to the process that uses most of the memory. In that way when MySQL does a free(), malloc library keeps that memory attached to the process , so that for next malloc() it does not have to ask kernel for the memory.

You can easily reduce the memory by writing a small C program that would calloc() more memory then what is available, but do keep in mind that this would slow MySQL doesn.

Not a bug.