# Fixing deallocation problem on Suse Linux using jemalloc instead of system malloc # TESTED ON opensuse-leap 15.6 # REF: https://mariadb.com/kb/en/using-mariadb-with-tcmalloc-or-jemalloc/ # INSTALL JEMALLOC commands from page: https://software.opensuse.org/download/package?package=jemalloc&project=home%3Acrameleon%3Ajemalloc zypper addrepo https://download.opensuse.org/repositories/home:crameleon:jemalloc/openSUSE_Tumbleweed/home:crameleon:jemalloc.repo zypper refresh zypper install jemalloc vi /usr/lib/systemd/system/mariadb.service # IN THE BLOCK FOR SERVICE, ADD THE LINE: Environment=LD_PRELOAD=/usr/lib64/libjemalloc.so.2 systemctl daemon-reload # In the .cnf file, increase innodb_buffer_pool_size from 1073741824 (1G) to 1288500000 innodb_buffer_pool_size = 1288500000 systemctl restart mariadb # Retry the insert of 358400 rows (1k each row) on table memtest.BIGMEMORY suse:~ # top -b -n 1 -p 16138 | tail -2 PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 16138 mysql 20 0 3528020 1.605g 5376 S 0.000 83.30 0:12.91 mysqld suse:~ # mariadb -Ae "truncate table memtest.BIGMEMORY;" suse:~ # top -b -n 1 -p 16138 | tail -2 PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 16138 mysql 20 0 3528020 490064 8064 S 0.000 24.26 0:12.98 mysqld suse:~ # mariadb Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 7 Server version: 10.11.9-MariaDB-log MariaDB package Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> select @@version_malloc_library; +------------------------------------------------------------+ | @@version_malloc_library | +------------------------------------------------------------+ | jemalloc 5.3.0-0-g54eaed1d8b56b1aa528be3bdd1877e59c56fa90c | +------------------------------------------------------------+ 1 row in set (0.000 sec) MariaDB [(none)]>