How to set malloc-lib in mysql 5.7 in ubuntu 18.04 LTS
I had to do a bit more to get this to work.  This worked for me.  First the problem:
Starting in Ubuntu 18.04, Percona / MySQL are configured thru systemd
This means setting malloc-lib= in my.cnf no longer works!  It also no longer works &quot;out of the box&quot; (at least not for me).
So how do we get this to work?

Create an override.conf file to load jemalloc.  This is done using systemd controls.
sudo systemctl edit mysql

This will pop up an editor.  Unless this has been done before, odds are this will be a blank new file. Enter this in:
[Service]
Environment=&quot;LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1&quot;

Then sudo systemctl daemon-reload which loads the override.conf

Then sudo systemctl restart mysql which restarts the server


Resources:

The heavy lifting: https://dev.mysql.com/doc/mysql-installation-excerpt/8.0/en/using-systemd.html
Percona blog article: https://www.percona.com/blog/2017/01/03/enabling-and-disabling-jemalloc-on-percona-server/

The instructions on how to verify the jemalloc is actually being used are key.