Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(547)

Side by Side Diff: base/allocator/README

Issue 434067: Branch the files in the shim layer that switches between the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/allocator/allocator.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
1 Notes about the Chrome port of tcmalloc & jemalloc. 1 Notes about the Chrome memory allocator.
2 2
3 Background 3 Background
4 ---------- 4 ----------
5 We use this library as a generic way to fork into any of several allocators. 5 We use this library as a generic way to fork into any of several allocators.
6 Currently we can, at runtime, switch between: 6 Currently we can, at runtime, switch between:
7 the default windows allocator 7 the default windows allocator
8 the windows low-fragmentation-heap 8 the windows low-fragmentation-heap
9 tcmalloc 9 tcmalloc
10 jemalloc (the heap used most notably within Mozilla Firefox) 10 jemalloc (the heap used most notably within Mozilla Firefox)
11 11
12 The mechanism for hooking LIBCMT in windows is rather tricky. The core 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 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 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 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, 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 17 we can now link against the library and provide custom versions of the
18 allocator related functionality. 18 allocator related functionality.
19 19
20 20
21 Source code 21 Source code
22 ----------- 22 -----------
23 Everything within the directory tcmalloc/tcmalloc is pulled directly from the 23 This directory contains just the allocator (i.e. shim) layer that switches
24 google-perftools repository. For the most part, tcmalloc is a stock build 24 between the different underlying memory allocation implementations.
25 from there.
26 25
27 We have forked a few files. We always push our changes upstream, so over 26 The tcmalloc and jemalloc libraries originate outside of Chromium
28 time the forked files should disappear. Currently forked files include: 27 and exist in ../../third_party/tcmalloc and ../../third_party/jemalloc
29 page_heap.cc 28 (currently, the actual locations are defined in the allocator.gyp file).
30 port.cc 29 The third party sources use a vendor-branch SCM pattern to track
31 system-alloc.cc 30 Chromium-specific changes independently from upstream changes.
32 system-alloc.h
33 tcmalloc.cc
34 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 ----------------------
35 Adding a new allocator requires definition of the following five functions: 38 Adding a new allocator requires definition of the following five functions:
39
36 extern "C" { 40 extern "C" {
37 bool init(); 41 bool init();
38 void* malloc(size_t s); 42 void* malloc(size_t s);
39 void* realloc(void* p, size_t s); 43 void* realloc(void* p, size_t s);
40 void free(void* s); 44 void free(void* s);
41 size_t msize(void* p); 45 size_t msize(void* p);
42 } 46 }
43 47
44 All other allocation related functions (new/delete/calloc/etc) have been 48 All other allocation related functions (new/delete/calloc/etc) have been
45 implemented generically to work across all allocators. 49 implemented generically to work across all allocators.
46 50
47 51
48 Usage 52 Usage
49 ----- 53 -----
50 You can use the different allocators by setting the environment variable 54 You can use the different allocators by setting the environment variable
51 CHROME_ALLOCATOR to: 55 CHROME_ALLOCATOR to:
52 "tcmalloc" - TC Malloc (default) 56 "tcmalloc" - TC Malloc (default)
53 "jemalloc" - JE Malloc 57 "jemalloc" - JE Malloc
54 "winheap" - Windows default heap 58 "winheap" - Windows default heap
55 "winlfh" - Windows Low-Fragmentation heap 59 "winlfh" - Windows Low-Fragmentation heap
56
57
58 Local modifications
59 -------------------
60 jemalloc has been modified slightly to work within the Chromium build.
OLDNEW
« no previous file with comments | « no previous file | base/allocator/allocator.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698