Home | History | Annotate | only in /external/chromium/base/allocator
Up to higher level directory
NameDateSize
allocator.gyp13-Nov-201216.9K
allocator_shim.cc13-Nov-20128.6K
allocator_shim.h13-Nov-2012703
allocator_unittests.cc13-Nov-201214.5K
generic_allocators.cc13-Nov-20123.2K
prep_libc.sh13-Nov-20121.3K
README13-Nov-20122.1K
unittest_utils.cc13-Nov-2012518
win_allocator.cc13-Nov-20121.1K

README

      1 Notes about the Chrome memory allocator.
      2 
      3 Background
      4 ----------
      5 We use this library as a generic way to fork into any of several allocators.
      6 Currently we can, at runtime, switch between:
      7    the default windows allocator
      8    the windows low-fragmentation-heap
      9    tcmalloc
     10    jemalloc (the heap used most notably within Mozilla Firefox)
     11 
     12 The mechanism for hooking LIBCMT in windows is rather tricky.  The core
     13 problem is that by default, the windows library does not declare malloc and
     14 free as weak symbols.  Because of this, they cannot be overriden.  To work
     15 around this, we start with the LIBCMT.LIB, and manually remove all allocator
     16 related functions from it using the visual studio library tool.  Once removed,
     17 we can now link against the library and provide custom versions of the 
     18 allocator related functionality.
     19 
     20 
     21 Source code
     22 -----------
     23 This directory contains just the allocator (i.e. shim) layer that switches
     24 between the different underlying memory allocation implementations.
     25 
     26 The tcmalloc and jemalloc libraries originate outside of Chromium
     27 and exist in ../../third_party/tcmalloc and ../../third_party/jemalloc
     28 (currently, the actual locations are defined in the allocator.gyp file).
     29 The third party sources use a vendor-branch SCM pattern to track
     30 Chromium-specific changes independently from upstream changes.
     31 
     32 The general intent is to push local changes upstream so that over
     33 time we no longer need any forked files.
     34 
     35 
     36 Adding a new allocator
     37 ----------------------
     38 Adding a new allocator requires definition of the following five functions:
     39 
     40   extern "C" {
     41     bool init();
     42     void* malloc(size_t s);
     43     void* realloc(void* p, size_t s);
     44     void free(void* s);
     45     size_t msize(void* p);
     46   }
     47 
     48 All other allocation related functions (new/delete/calloc/etc) have been
     49 implemented generically to work across all allocators.
     50 
     51 
     52 Usage
     53 -----
     54 You can use the different allocators by setting the environment variable
     55 CHROME_ALLOCATOR to:
     56    "tcmalloc"  - TC Malloc (default)
     57    "jemalloc"  - JE Malloc
     58    "winheap"   - Windows default heap
     59    "winlfh"    - Windows Low-Fragmentation heap
     60