# 8.0.29-21.1 Percona XtraDB Cluster - jemalloc not working (SOLVED)

**URL:** <https://forums.percona.com/t/8-0-29-21-1-percona-xtradb-cluster-jemalloc-not-working-solved/17720>\
**Category:** Percona XtraDB Cluster 8.x\
**Created:** [September 28, 2022, 2:10am UTC](https://forums.percona.com/t/8-0-29-21-1-percona-xtradb-cluster-jemalloc-not-working-solved/17720 "2022-09-28T02:10:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josias\_L\_G](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/josias_l_g/32/7916_2.png) [@Josias\_L\_G](https://forums.percona.com/u/Josias_L_G)\
**Post date:** [September 28, 2022, 2:10am UTC](https://forums.percona.com/t/8-0-29-21-1-percona-xtradb-cluster-jemalloc-not-working-solved/17720/1 "2022-09-28T02:10:46Z")

</div>

Hi.  
I trying to get jemalloc on 8.0.29-21.1 Percona XtraDB Cluster but not success.  
Even doing the manual startup (LD\_PRELOAD=/usr/local/lib/libjemalloc.so /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/var/lib/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock) the variable inside mysql not detect:  
mysql\> SHOW VARIABLES LIKE ‘%malloc%’;  
±-------------------±------+  
| Variable\_name | Value |  
±-------------------±------+  
| jemalloc\_detected | OFF |  
| jemalloc\_profiling | OFF |  
±-------------------±------+  
2 rows in set (0.01 sec)

The docs on percona blog is outdated.

Other thing is the build-ps/build-binary.sh  
There is the line: WITH\_JEMALLOC=’ ’  
How I can build with jemalloc included ?. I got several errors when try to include -DWITH\_JEMALLOC=ON on location where are others.  
If have some example file will help.

Thank you.

---

<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:** [September 28, 2022, 3:09pm UTC](https://forums.percona.com/t/8-0-29-21-1-percona-xtradb-cluster-jemalloc-not-working-solved/17720/2 "2022-09-28T15:09:25Z")

</div>

Hello @Josias_L_G  
This blog is from 2020 and appears to be up to date with MySQL 8.0. Is this the blog that you say isn’t working?

> **[Enabling jemalloc on Percona Server for MySQL 5.7 and 8.0 Series - Percona...](https://www.percona.com/blog/2020/12/02/enabling-jemalloc-on-percona-server-for-mysql-5-7-and-8-0-series/)**
>
> There are a few extra steps you need to take for enabling jemalloc on Percona Server for MySQL 5.7 and 8.0.X series.

I notice that your LD\_PRELOAD does not match the path in the blog. Did you properly install the jemalloc library using your OS package manager?

---

<div class="post-metadata">

**Author:** ![Josias\_L\_G](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/josias_l_g/32/7916_2.png) [@Josias\_L\_G](https://forums.percona.com/u/Josias_L_G)\
**Post date:** [September 28, 2022, 3:18pm UTC](https://forums.percona.com/t/8-0-29-21-1-percona-xtradb-cluster-jemalloc-not-working-solved/17720/3 "2022-09-28T15:18:05Z")

</div>

Hi there.  
Yes.  
I try to use LD\_PRELOAD on sysconfig too, however nothing inside mysql tell me about usage.  
The lsof -Pn -p $(pidof mysqld) | grep jemalloc return the loaded module, but no usage inside mysql.  
My last try was compile the jemalloc 5.3 (latest) and manually make the setting on LD\_PRELOAD (before this i use others like 3.6).

But before all this, what flag inside mysql i can use to view the jemalloc ?. The only command i localize the usage is SHOW VARIABLES LIKE ‘%malloc%’; but i don´t know if is related to jemalloc in compile time or the usage of LD\_PRELOAD.

---

<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:** [September 28, 2022, 4:16pm UTC](https://forums.percona.com/t/8-0-29-21-1-percona-xtradb-cluster-jemalloc-not-working-solved/17720/4 "2022-09-28T16:16:42Z")

</div>

[https://docs.percona.com/percona-server/8.0/performance/jemalloc-profiling.html#jemalloc-detected](https://docs.percona.com/percona-server/8.0/performance/jemalloc-profiling.html#jemalloc-detected)

jemalloc has to be custom compiled with additional flags to enable memory profiling with Percona MySQL. If the lsof returns that jemalloc is loaded, then MySQL is indeed using jemalloc but you will not be able to use the extra profiling features unless you custom compile jemalloc.
