R&D/OS

jemalloc build

sunshout 2015. 6. 23. 16:09

build


git clone https://github.com/jemalloc/jemalloc.git


cd  jemalloc

(사전 준비) apt-get install docbook-xsl

(빌드)

./autogen.sh

make dist

make

make install


test

g++ test.c -I/usr/local/include -ljemalloc


test.c

#include <stdio.h>

#include <jemalloc/jemalloc.h>


void

do_something()

{

  // Leak some memory.

  malloc(sizeof(int));


  malloc(512);

}


int

main(int argc, char **argv)

{

  malloc_stats_print(NULL, NULL, NULL);


    for (int i = 0; i < 500; ++i) {

    do_something();

  }

  // Dump allocator statistics to stderr.

  malloc_stats_print(NULL, NULL, NULL);

  return (0);

}


 

file  # of lines 

 설명

arena.c           3,160  
atomic.c                2  
base.c             174  
bitmap.c               78  
chunk.c             573  
chunk_dss.c             213  
chunk_mmap.c             205  
ckh.c             568  
ctl.c           2,129  
extent.c               53  
hash.c                2  
huge.c             434  
jemalloc.c           2,548  
mb.c                2  
mutex.c             149  
prof.c           2,217  
quarantine.c             183  
rtree.c             127  
stats.c             638  
tcache.c             537  
tsd.c             190  
util.c             650  
valgrind.c               34  
zone.c             274

 OSX 용

total        15,140  


참조:

https://github.com/jemalloc/jemalloc

http://analytaps.net/JEMalloc

A Scalable Concurrent malloc(3) Implementation for FreeBSD : https://people.freebsd.org/~jasone/jemalloc/bsdcan2006/jemalloc.pdf