Redis記憶體配置簡單分析

來源:互聯網
上載者:User

標籤:

             Redis記憶體管理             1.Redis記憶體申請記憶體方式有三種:     (1)系統內建的malloc/free方式進行申請/釋放。     (2)使用tcmalloc進行記憶體的申請/釋放。     (3)使用jemalloc進行記憶體申請/釋放。    /* Explicitly override malloc/free etc when using tcmalloc. */    #if defined(USE_TCMALLOC)    #define malloc(size) tc_malloc(size)    #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)    #define 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)    #endif2.記憶體計數器上使用了gcc的一組原子操作,實現的功能就是在used_memory+n的操作//1.先做操作,再返回變化後的值//2.先返回變化前的值,再做操作#if defined(__ATOMIC_RELAXED)#define update_zmalloc_stat_add(__n) __atomic_add_fetch(&used_memory, (__n), __ATOMIC_RELAXED) //used_memory+=n;#define update_zmalloc_stat_sub(__n) __atomic_sub_fetch(&used_memory, (__n), __ATOMIC_RELAXED) //used_memory-=n;#elif defined(HAVE_ATOMIC)#define update_zmalloc_stat_add(__n) __sync_add_and_fetch(&used_memory, (__n)) //used_memory+=n;#define update_zmalloc_stat_sub(__n) __sync_sub_and_fetch(&used_memory, (__n)) //used_memory-=n;#else    3.還有一部函數擷取系統的配置資訊

 

Redis記憶體配置簡單分析

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.