redis编译问题

在编译redis时,出现以下问题

In file included from adlist.c:34:0:
zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
 #include <jemalloc/jemalloc.h>

  是因为编译redis默认使用的分配器是jemalloc,所以想要解决如上问题的话,有两种方式

  

  第一种 

    yum -y install jemalloc-devel

  第二种

    我们可以查看解压之后的redis文件夹,里面有一个README.md

    

    Allocator
    ---------

    Selecting a non-default memory allocator when building Redis is done by setting
    the `MALLOC` environment variable. Redis is compiled and linked against libc
    malloc by default, with the exception of jemalloc being the default on Linux
    systems. This default was picked because jemalloc has proven to have fewer
    fragmentation problems than libc malloc.

    To force compiling against libc malloc, use:

        % make MALLOC=libc

    To compile against jemalloc on Mac OS X systems, use:

        % make MALLOC=jemalloc

  通过查看文件我们可以知道,我们可以使用如下命令,从而使用改变分配器

    make MALLOC=libc    

这两种方法都可以解决上述的问题,希望可以帮到大家。

posted @ 2018-11-02 09:52  情浅凉心  阅读(533)  评论(0编辑  收藏  举报