Next, Redis uses a different memory allocator

Source: Internet
Author: User

Reference article: http://blog.sina.com.cn/s/blog_51df3eae01016peu.html

We know that Redis does not implement its own memory pool, and does not add its own stuff to the standard system memory allocator. Therefore, the performance and fragmentation rate of the system memory allocator can have some performance impact on Redis.

In the zmalloc.c source of Redis, we can see the following code:

#if defined (use_tcmalloc) #define malloc (size) tc_malloc (size) Wuyi #define CALLOC (count,size) tc_calloc (count,size) #define REALLOC (ptr,size) tc_realloc (ptr,size) #define FREE (PTR) tc_free (PTR) #elif defined (use_jemalloc) #def INE malloc (size) je_malloc (size) #define CALLOC (count,size) je_calloc (count,size) #define REALLOC (ptr,size) je_ ReAlloc (ptr,size) #define FREE (PTR) je_free (PTR) #endif

As we can see from the code above, Redis will first determine whether to use Tcmallocwhen compiling, and if so, replace the function implementation in the standard libc with the tcmalloc corresponding function. The second is to determine whether Jemalloc makes, and finally if not used, the standard LIBC memory management functions.

The installation method for installing Tcmalloc is listed in the

Reference, so I'll say Jemalloc installation method

 tar  jxf jemalloc-3.6 . 0 . tar  .BZ2CD jemalloc -0   /configure  make Use_jemalloc=yes force_libc_ Malloc=yes #指定用jemalloc  make  install   
CP -a/root/jemalloc-3.6 . 0 /include/jemalloc/USR/INCLUDE/CD. Cat/etc/ld.so.conf.d/local_lib.confecho "/usr/local/lib" >/etc/ld.so.conf.d/local_lib.conf/sbin/ldconfig

#至于是选择tcmalloc还是jemalloc, I'm looking at a man's liking.

Ptmalloc is the GLIBC memory allocation management module

Tcmalloc is Google's memory allocation management module

Jemalloc is BSD's memory allocation management module

Next, Redis uses a different memory allocator

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.