[MDEV-32644] Possible memory leak with 0 active connection , Memory utilization is high Created: 2023-11-01 Updated: 2023-12-29 Resolved: 2023-12-15 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Server |
| Affects Version/s: | 10.5.22 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Critical |
| Reporter: | Pramod Mahto | Assignee: | Kwangbock Lee |
| Resolution: | Incomplete | Votes: | 0 |
| Labels: | triage | ||
| Description |
|
With no active connection to (idle) MariaDB server 10.5.22 still the memory usage is high:- Checking on the OS side we it goes up to 45GB aprox. There is like 10GB no explanations. cat /proc/$mariadb_pid/status
While testing with other versions with default parameters fresh installation without any user's DB/Tables :- MariaDB 10.5.9
10.5.17
10.5.22
|
| Comments |
| Comment by Sergei Golubchik [ 2023-11-03 ] | ||||||||||||||||||||||||||||
|
Is that memory usage on startup? That is, you start the server — no connections yet — and it takes 35GB? | ||||||||||||||||||||||||||||
| Comment by MikaH [ 2023-11-06 ] | ||||||||||||||||||||||||||||
|
What is the OS and version? | ||||||||||||||||||||||||||||
| Comment by Vignesh Viswanathan [ 2023-11-08 ] | ||||||||||||||||||||||||||||
|
Hi, We are observing a similar kind of high memory utilization issue in the MariaDB 10.5.11 deployed on a Windows Server 2019 Standard containing 16 GB RAM , which leads the server becoming unusable till a reboot. This repeats every 14 days. There are indications in the Application event logs in the server of a leaking memory process - consuming all available memory and causing multiple applications to crash due to System.OutOfMemoryException. Microsoft's RADAR_PRE_LEAK_64 entry in the Application Log is indicating mysqldb to be a the probable cause. We found the below entry in the system event log : Please let us know if any more details are required from our end. Or should we raise a new bug for this ? Thanks, | ||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2023-11-09 ] | ||||||||||||||||||||||||||||
|
VVignesh, could you use UMDH, to find out the cause of the memory leak? The tool is described here https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/using-umdh-to-find-a-user-mode-memory-leak. There is a blog entry https://planet.mysql.com/entry/?id=15423 that describes how to analyze Windows memory leaks, for mysqld.exe process. It is a 15 years old article, some things work differently (apparently the download of Debugging tools for Windows) , but the otherwise the description is still accurate. | ||||||||||||||||||||||||||||
| Comment by Michael Widenius [ 2023-11-29 ] | ||||||||||||||||||||||||||||
|
mysqld.exe (2968) consumed 2546798592 bytes | ||||||||||||||||||||||||||||
| Comment by Michael Widenius [ 2023-11-29 ] | ||||||||||||||||||||||||||||
|
It is normal that MariaDB does not release memory back to the OS. The memory will be reused be future queries. If using MariaDB on Linux, one can enable jemalloc to get better control of the memory allocations. It may be that jemalloc is also better in giving back some memory to the OS thanks to less memory fragmentation. See https://mariadb.com/kb/en/using-mariadb-with-tcmalloc-or-jemalloc/ for details of how to enable it. | ||||||||||||||||||||||||||||
| Comment by Michael Widenius [ 2023-11-29 ] | ||||||||||||||||||||||||||||
|
I did a quick check of memory usage of MariaDB on my development machine: Testing the memory used on my development system running a debug version of MariaDB 10.6.16: ((/my/maria-10.6/sql)) ls -lh mariadbd The above numbers are big as this is a debug binary with a lot of symbols. MariaDB [test]> show global status like "Innodb_buffer_pool_bytes_data";
------------------------------
------------------------------
--------------
--------------
--------------
--------------
------------------------
------------------------
---------------------------
--------------------------- MariaDB [test]> select 134217728+16777216+8388608+134217728;
--------------------------------------
-------------------------------------- MariaDB [test]> select (134217728+16777216+8388608+134217728)/1024/1024;
--------------------------------------------------
+-------------------------------------------------- This shows that the most of the allocated memory are assigned to storage engine buffers. ps shows 1205M of memory usage for the mariadbd process. Some of this is virtual mapped cat /proc/34213/status | grep Vm Vmdata kind of matches that above numbers. I did a quick search on Google: "VMsize is the "address space" that the process has in use: the number The fact that we are using threads, may cause VmSize to be high, but as ((/my/maria-10.6/sql)) cat /proc/35413/smaps | grep -i pss | awk ' {Total+=$2}END {print Total/1024" MB"}' top shows when mariadbd is running: without mariadbd: Restarted: Which shows a 100M difference (which is a bit too small should be closer to 200M, but still The main point is that I cannot see any extended memory usage on my machine, so there is no way to repeat it. Please include full configuration of your MariaDB server so that we can analyze what is happening. When monitoring MariaDB, running the following queries every 15 second or every minute would probably help locate if the problem is in MariaDB: In processlist, especially the column MAX_MEMORY_USED should be helpful | ||||||||||||||||||||||||||||
| Comment by Michael Widenius [ 2023-11-30 ] | ||||||||||||||||||||||||||||
|
If possibly, you can try disabling hugepages as it may disable malloc from freeing free memory to the system: echo madvise | sudo tee /sys/kernel/mm/transparent_hugepage/enabled See https://blog.nelhage.com/post/transparent-hugepages/ for more information |