Percona 5.6.14-56 very high memory usage.

I recently, blindly, updated to Percona 5.6 via the repos. I’m not running a very sophisticated database (it’s a small user group (<10) mostly for displaying timed data that can be inputed via an php interface). I have a few databases with the average size of less than a MB, the most users that are ever connected at the same time is about 5.

My server is a dedicated VSS with 1GB of ram. Percona 5.5 would use around 200-300MB of ram total when running.

However, after updating to Percona 5.6, when the server starts it instantly uses about 450MB of Physical memory and 1.5GB of virtual memory. These amounts seem to be stable once the program launches.

from PS

mysql 8877 0.0 30.0 1254936 473268 pts/0 Sl 10:35 0:05 /usr/sbin/mysqld --ba

VSZ
1254936KB

RSS
473268KB 450MB

I’ve optimized all my settings and there shouldn’t be a problem: from MySQLTuner:

Maximum possible memory usage: 338.9M (22% of installed RAM)
Highest usage of available connections: 0% (1/151)
Key buffer size / total MyISAM indexes: 8.0M/45.0K
Query cache efficiency: 0.0% (0 cached / 26 selects)
Query cache prunes per day: 0
Sorts requiring temporary tables: 0% (0 temp sorts / 1 sorts)
Temporary tables created on disk: 10% (10 on disk / 97 total)
Thread cache hit rate: 94% (1 created / 18 connections)
Table cache hit rate: 62% (111 open / 178 opened)
Open file limit used: 0% (48/470K)
Table locks acquired immediately: 100% (70 immediate / 70 locks)
InnoDB data size / buffer pool: 864.0K/128.0M

using pmap i see there are a bunch of 10MB blocks of memory allocated, which makes sense, however, I see 2 huge chunks of memory allocated for reasons unknown, which I think are the problem, I cut out some of the early address because i hit the posting character limit:

[url]http://pastebin.com/1TeQVZxE[/url]

it’s just anon memory allocation, which I don’t understand why it needs to allocate so much. Seems like a bug, any help would be GREATLY appreciated, I would like to get my server down to 200-300MB again.

Hello,
I can confirm this problem - update from MySQL 5.5 to Percona 5.6.14-60 on Debian Wheezy.

mysqltuner:
[–] Up for: 21h 59m 32s (1M q [15.143 qps], 161K conn, TX: 1B, RX: 213M)
[–] Reads / Writes: 69% / 31%
[–] Total buffers: 309.0M global + 1.1M per thread (32 max threads)
[OK] Maximum possible memory usage: 343.0M (22% of installed RAM)
[!!] Highest connection usage: 90% (29/32)
[OK] Key buffer size / total MyISAM indexes: 80.0M/384.9M
[OK] Key buffer hit rate: 99.4% (53M cached / 330K reads)
[!!] Query cache efficiency: 0.0% (0 cached / 596K selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (127 temp sorts / 107K sorts)
[!!] Joins performed without indexes: 1238
[OK] Temporary tables created on disk: 10% (12K on disk / 123K total)
[OK] Thread cache hit rate: 99% (114 created / 161K connections)
[OK] Table cache hit rate: 33% (509 open / 1K opened)
[OK] Open file limit used: 7% (389/5K)
[OK] InnoDB data size / buffer pool: 186.6M/196.0M

top:
USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
mysql 20 0 1233m 729m 7876 S 1.7 47.5 63:11.59 /usr/sbin/mysqld

pmap output:
[url]http://pastebin.com/1mjRwvAv[/url]

I can also confirm this problem. I went to a fresh 5.6 install (not an upgrade) and imported the data that was dumped from mysql. Percona is performing well, but memory consumption increases (slowly) monotonically and doesn’t come back down. This is independent of actual load.

Dear Percona,
I believe that this is a major issue with your product and it should be addressed quickly.
Could you inform us about the progress of analyzing/fixing of this bug?
I could add, that in my case it was Debian wheezy x64 on OpenVZ VPS server (kernel 2.6).

Just checking in on this. Wanted to add I’m using
Based on the number of views this thread has (more than any other post), I’m thinking a lot more people are having this problem.

There is absolutely nothing we can do right now to alleviate this issue, the users are helpless, please update us.

I have the same issue, MySQL’s memory usage almost doubled. If I can’t fix this, I will have to go back to MySQL 5.5

This is completely unacceptable.

For me, it seems to be very related to table_open_cache:

table_open_cache=32K: 1560M
table_open_cache=64K: 2600M
table_open_cache=128K: 3900M

other settings:
max_connections = 100
join_buffer_size = 6M
innodb_buffer_pool_size = 1G
query_cache_size = 300M

Data in MyISAM tables: 3K (Tables: 12)
Data in InnoDB tables: 863M (Tables: 996)

Hi, we noticed higher VSZ memory usage as well. We could fix it by turning the performance_schema=off. It was disabled by default in 5.5 and has been enabled by default since 5.6.6 (see [URL]http://dev.mysql.com/doc/relnotes/mysql/5.6/en/news-5-6-6.html[/URL]).

thank you S0enke!!! adding performance_schema = off

to my config also greatly reduced memory usage for me as well.

Disabling performance_schema did the trick.
Thank you!

Regarding high memory usage in version 5.6, related to performance_schema, there is a bug report :
[url]MySQL Bugs: #68514: 5.6 huge memory usage with max_connections parameter
Unfortunately, it wasn’t accepted as valid bug, see all the discussion in comments though.

Rogers,
“I believe that this is a major issue with your product and it should be addressed quickly.”
Performance schema is a functionality coming from upstream MySQL developed by Oracle crew, we just use exactly the same functionality in Percona Server.
Do you notice smaller memory footprint in MySQL 5.6 vs PS 5.6? If yes, let us know.

Btw here you can find quick feature comparison between upstream and Percona versions:
[url]Percona Server for MySQL 8.0 - Documentation — Percona Server 8.0 Documentation

What helped me was on CentOS was changing the memory allocator:


yum install jemalloc-devel

and add to my.cnf:


[mysqld_safe]
malloc-lib = /usr/lib64/libjemalloc.so.1