Skip to main content

Enable jemalloc for MySQL 5.7 WHM Server

Comments

6 comments

  • cPanelLauren
    I would suggest checking out their documentation here:
    0
  • kdean
    Centos 7 requires more steps because it doesn't work when just editing the my.cnf I use the similar TCMALLOC and had to create a conf file at /etc/systemd/system/mysqld.service.d/ I used limits.conf but I believe it doesn't matter what you use. You would put the following in it [Service] Environment="LD_PRELOAD=/usr/lib64/libjemalloc.so.1"
    Here's a link to tell you how to use systemctl edit to do it. I had to use the same method to change memory limits (LimitNOFILE, LimitMEMLOCK) that no longer works in my.cnf as well. systemd brought about these changes.
    0
  • clickround
    Hi Thanks for your reply. is there a specific name i must name the new file inside " mysqld.service.d "? mention "TCMALLOC", in your opinion and experience which is one is better to use with mysql: TCMALLOC or jemalloc? since iam facing a problem with mysql that with time memory consume and increase to high level even if no load at that time but as some memory not free. Thanks,
    0
  • kdean
    You can name it limits.conf like I did. I have both tcmalloc and jemalloc installed just in case but I've only ever activated tcmalloc. From what I've read jemalloc is a good choice due to lower memory overhead and may be faster that tcmalloc with larger number of threads. Low threads tcmalloc wins. I should test jemalloc as well, but just never got around to it. I installed the mallocs for the same reason. MySQL 5.7 built in memory allocator leaks like a sieve and just grows and grows. tcmalloc solved that problem for me but I'm sure that jemalloc should do the same if not better for you.
    0
  • clickround
    ok, very thanks i will try it.
    0
  • kdean
    Look back at things, I think I went with tcmalloc because the latest version I could find for Centos was from 2017, while the latest for jemalloc was from 2014. Both have more recent versions, so not sure why there's not more recent versions for either in the repositories. Not sure if there's some issue with later versions if custom compiled, so I just stuck with what I've had.
    0

Please sign in to leave a comment.