# There is serious memory leak

**URL:** <https://forums.percona.com/t/there-is-serious-memory-leak/15422>\
**Category:** Percona Server for MySQL 8.0\
**Created:** [April 27, 2022, 1:54am UTC](https://forums.percona.com/t/there-is-serious-memory-leak/15422 "2022-04-27T01:54:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![azuryy](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@azuryy](https://forums.percona.com/u/azuryy)\
**Post date:** [April 27, 2022, 1:54am UTC](https://forums.percona.com/t/there-is-serious-memory-leak/15422/1 "2022-04-27T01:54:50Z")

</div>

Download Percona-Server-8.0.27-18-Linux.x86\_64.glibc2.17-minimal.tar.gz from [percona.com](http://percona.com),

there are serious memory leak with lot’s of monitor.

there is jemalloc under Percona-Server-8.0.27/lib/mysql/lib/libjemalloc.so.1 by default and percona use it by default, I am not sure the version of this jemalloc, but mysql run out memory after startup one day.

I download source jemalloc-5.2.1 from official website, change LD\_PRELOAD variable and deleted percona default jemalloc, everything goes well now.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [April 27, 2022, 3:44pm UTC](https://forums.percona.com/t/there-is-serious-memory-leak/15422/2 "2022-04-27T15:44:54Z")

</div>

Hello @azuryy,  
I checked with our engineering software team on this and there isn’t any other reports of memory leaks. Do you have any sort of performance analysis from PMM during your leak that you can share?

---

<div class="post-metadata">

**Author:** ![kalahariresearch](https://avatars.discourse-cdn.com/v4/letter/k/aca169/32.png) [@kalahariresearch](https://forums.percona.com/u/kalahariresearch)\
**Post date:** [May 3, 2022, 12:37pm UTC](https://forums.percona.com/t/there-is-serious-memory-leak/15422/3 "2022-05-03T12:37:30Z")

</div>

I think it might be related, I have experienced (on multiple servers) memory leaks, but more specifically on INSERT actions. The time it usually took to synchronise a database from MS access to Percona MySQL has gone up 10 fold. I’ve worked with the developers of the synchronisation software, but the problem seems not to be there, but mainly on the INSERT actions.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [May 3, 2022, 2:33pm UTC](https://forums.percona.com/t/there-is-serious-memory-leak/15422/4 "2022-05-03T14:33:16Z")

</div>

@kalahariresearch,  
There can be many reasons why you are experiencing poor INSERT performance. What we really need to see if performance graphs from MySQL and the OS while you are seeing issues in order to determine the root cause.

---

<div class="post-metadata">

**Author:** ![kalahariresearch](https://avatars.discourse-cdn.com/v4/letter/k/aca169/32.png) [@kalahariresearch](https://forums.percona.com/u/kalahariresearch)\
**Post date:** [May 4, 2022, 8:18am UTC](https://forums.percona.com/t/there-is-serious-memory-leak/15422/5 "2022-05-04T08:18:20Z")

</div>

@matthewb  
Please see below.  
I’ll also post my mysql config, the weird thing is that without changing anything, the performance dropped after the update.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/a/a9a2bb3e3a39403e9f11b0b0e83dda94128a28cb.png)

```auto
[mysql]

# CLIENT #
#port = 3306
#socket = /var/run/mysqld/mysqld.sock

[mysqld]

# GENERAL #
#user = mysql
default_storage_engine = InnoDB
#socket = /var/run/mysqld/mysqld.sock
#pid_file = /var/run/mysqld/mysqld.pid

# SAFETY #
max_allowed_packet = 16M
max_connect_errors = 1000000
skip_name_resolve
#sql_mode = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY
sql_mode =
sysdate_is_now = 1
innodb = FORCE
innodb_strict_mode = 1

# BINARY LOGGING #
#log_bin = /var/log/mysql/mysql-bin
expire_logs_days = 14
sync_binlog = 1

# CACHES AND LIMITS #
tmp_table_size = 32M
max_heap_table_size = 32M
#query_cache_type = 0
#query_cache_size = 0
max_connections = 500
thread_cache_size = 50
open_files_limit = 65535
table_definition_cache = 1024
table_open_cache = 2048

# INNODB #
innodb_flush_method = O_DIRECT
innodb_log_files_in_group = 2
innodb_log_file_size = 1536M
innodb_flush_log_at_trx_commit = 0
innodb_file_per_table = 1
innodb_buffer_pool_size = 8000M
innodb_buffer_pool_instances = 1
innodb_read_io_threads = 64
innodb_write_io_threads = 64
innodb_fast_shutdown = 0

# LOGGING #
#log_error = /var/log/mysql/mysql-error.log
#log_queries_not_using_indexes = 1
#slow_query_log = 1
#slow_query_log_file = /var/log/mysql/mysql-slow.log

```

---

<div class="post-metadata">

**Author:** ![kalahariresearch](https://avatars.discourse-cdn.com/v4/letter/k/aca169/32.png) [@kalahariresearch](https://forums.percona.com/u/kalahariresearch)\
**Post date:** [May 4, 2022, 8:18am UTC](https://forums.percona.com/t/there-is-serious-memory-leak/15422/6 "2022-05-04T08:18:51Z")

</div>

Since I can only post one picture, here the performance graphs.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/5/520631172b8e27a5acab492468c230ff65068cad.png)

---

<div class="post-metadata">

**Author:** ![azuryy](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@azuryy](https://forums.percona.com/u/azuryy)\
**Post date:** [May 5, 2022, 2:32am UTC](https://forums.percona.com/t/there-is-serious-memory-leak/15422/7 "2022-05-05T02:32:26Z")

</div>

Thanks @matthewb ,

I don’t have perf analysis now, but I remember clearly is that, command ‘free -m’ to see, available memory only 600MB+(innodb buffer pool 96GB) after running mysqld 10 hours, and during these 10 hours, I’ve noticed the system memory was consumed increasingly.

I only do the following:

1. download jemalloc-5.2.1 source code and compile/install it to /usr/lib/.
2. stop mysqld
3. delete $Percona/lib/mysql/lib/ **libjemalloc.so.1**
4. export LD\_PRELOAD to /usr/lib/ **libjemalloc.so.2**

then, using ‘free -m’ command to check system memory consuming, it’s normal(avalable memory 87G) after running mysqld 10 hours.

---

<div class="post-metadata">

**Author:** ![azuryy](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@azuryy](https://forums.percona.com/u/azuryy)\
**Post date:** [May 6, 2022, 4:31am UTC](https://forums.percona.com/t/there-is-serious-memory-leak/15422/8 "2022-05-06T04:31:03Z")

</div>

One suggestion to Percona is upgrade jemalloc to 5.2.x which bundled with Percona MySQL server and update tar ball on the website.

---

<div class="post-metadata">

**Author:** ![kalahariresearch](https://avatars.discourse-cdn.com/v4/letter/k/aca169/32.png) [@kalahariresearch](https://forums.percona.com/u/kalahariresearch)\
**Post date:** [May 11, 2022, 11:27am UTC](https://forums.percona.com/t/there-is-serious-memory-leak/15422/9 "2022-05-11T11:27:54Z")

</div>

@matthewb, would you be able to give me feedback on the posted config and performance charts?

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [May 11, 2022, 5:10pm UTC](https://forums.percona.com/t/there-is-serious-memory-leak/15422/10 "2022-05-11T17:10:28Z")

</div>

Your config looks very normal. Unfortunately, your performance charts don’t show anything related to memory usage of the OS. I can see many other things in your `top` screenshot (php, postgresql, nodejs, etc) All of those are competing with MySQL for memory. You may not be seeing a leak, you may just be seeing competition for memory. Increase the amount of memory on the OS by 4-6GB and see if this is still an issue.
