OLD | NEW |
1 This document describes how malloc / new calls are routed in the various Chrome | 1 This document describes how malloc / new calls are routed in the various Chrome |
2 platforms. | 2 platforms. |
3 | 3 |
4 Bare in mind that the chromium codebase does not always just use `malloc()`. | 4 Bare in mind that the chromium codebase does not always just use `malloc()`. |
5 Some examples: | 5 Some examples: |
6 - Large parts of the renderer (Blink) use two home-brewed allocators, | 6 - Large parts of the renderer (Blink) use two home-brewed allocators, |
7 PartitionAlloc and BlinkGC (Oilpan). | 7 PartitionAlloc and BlinkGC (Oilpan). |
8 - Some subsystems, such as the V8 JavaScript engine, handle memory management | 8 - Some subsystems, such as the V8 JavaScript engine, handle memory management |
9 autonomously. | 9 autonomously. |
10 - Various parts of the codebase use abstractions such as `SharedMemory` or | 10 - Various parts of the codebase use abstractions such as `SharedMemory` or |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 `../../third_party/tcmalloc` (currently, the actual location is defined in the | 80 `../../third_party/tcmalloc` (currently, the actual location is defined in the |
81 allocator.gyp file). The third party sources use a vendor-branch SCM pattern to | 81 allocator.gyp file). The third party sources use a vendor-branch SCM pattern to |
82 track Chromium-specific changes independently from upstream changes. | 82 track Chromium-specific changes independently from upstream changes. |
83 | 83 |
84 The general intent is to push local changes upstream so that over | 84 The general intent is to push local changes upstream so that over |
85 time we no longer need any forked files. | 85 time we no longer need any forked files. |
86 | 86 |
87 | 87 |
88 Unified allocator shim | 88 Unified allocator shim |
89 ---------------------- | 89 ---------------------- |
90 On most platform, Chrome overrides the malloc / operator new symbols (and | 90 On most platforms, Chrome overrides the malloc / operator new symbols (and |
91 corresponding free / delete and other variants). This is to enforce security | 91 corresponding free / delete and other variants). This is to enforce security |
92 checks and lately to enable the | 92 checks and lately to enable the |
93 [memory-infra heap profiler][url-memory-infra-heap-profiler]. | 93 [memory-infra heap profiler][url-memory-infra-heap-profiler]. |
94 Historically each platform had its special logic for defining the allocator | 94 Historically each platform had its special logic for defining the allocator |
95 symbols in different places of the codebase. The unified allocator shim is | 95 symbols in different places of the codebase. The unified allocator shim is |
96 a project aimed to unify the symbol definition and allocator routing logic in | 96 a project aimed to unify the symbol definition and allocator routing logic in |
97 a central place. | 97 a central place. |
98 | 98 |
99 - Full documentation: [Allocator shim design doc][url-allocator-shim]. | 99 - Full documentation: [Allocator shim design doc][url-allocator-shim]. |
100 - Current state: Available and enabled by default on Linux, CrOS and Android. | 100 - Current state: Available and enabled by default on Android, CrOS, Linux, |
| 101 Mac OS and Windows. |
101 - Tracking bug: [https://crbug.com/550886][crbug.com/550886]. | 102 - Tracking bug: [https://crbug.com/550886][crbug.com/550886]. |
102 - Build-time flag: `use_experimental_allocator_shim`. | 103 - Build-time flag: `use_allocator_shim`. |
103 | 104 |
104 **Overview of the unified allocator shim** | 105 **Overview of the unified allocator shim** |
105 The allocator shim consists of three stages: | 106 The allocator shim consists of three stages: |
106 ``` | 107 ``` |
107 +-------------------------+ +-----------------------+ +----------------+ | 108 +-------------------------+ +-----------------------+ +----------------+ |
108 | malloc & friends | -> | shim layer | -> | Routing to | | 109 | malloc & friends | -> | shim layer | -> | Routing to | |
109 | symbols definition | | implementation | | allocator | | 110 | symbols definition | | implementation | | allocator | |
110 +-------------------------+ +-----------------------+ +----------------+ | 111 +-------------------------+ +-----------------------+ +----------------+ |
111 | - libc symbols (malloc, | | - Security checks | | - tcmalloc | | 112 | - libc symbols (malloc, | | - Security checks | | - tcmalloc | |
112 | calloc, free, ...) | | - Chain of dispatchers| | - glibc | | 113 | calloc, free, ...) | | - Chain of dispatchers| | - glibc | |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 Related links | 188 Related links |
188 ------------- | 189 ------------- |
189 - [Unified allocator shim doc - Feb 2016][url-allocator-shim] | 190 - [Unified allocator shim doc - Feb 2016][url-allocator-shim] |
190 - [Allocator cleanup doc - Jan 2016][url-allocator-cleanup] | 191 - [Allocator cleanup doc - Jan 2016][url-allocator-cleanup] |
191 - [Proposal to use PartitionAlloc as default allocator](https://crbug.com/339604
) | 192 - [Proposal to use PartitionAlloc as default allocator](https://crbug.com/339604
) |
192 - [Memory-Infra: Tools to profile memory usage in Chrome](/docs/memory-infra/REA
DME.md) | 193 - [Memory-Infra: Tools to profile memory usage in Chrome](/docs/memory-infra/REA
DME.md) |
193 | 194 |
194 [url-allocator-cleanup]: https://docs.google.com/document/d/1V77Kgp_4tfaaWPEZVxN
evoD02wXiatnAv7Ssgr0hmjg/edit?usp=sharing | 195 [url-allocator-cleanup]: https://docs.google.com/document/d/1V77Kgp_4tfaaWPEZVxN
evoD02wXiatnAv7Ssgr0hmjg/edit?usp=sharing |
195 [url-memory-infra-heap-profiler]: /docs/memory-infra/heap_profiler.md | 196 [url-memory-infra-heap-profiler]: /docs/memory-infra/heap_profiler.md |
196 [url-allocator-shim]: https://docs.google.com/document/d/1yKlO1AO4XjpDad9rjcBOI1
5EKdAGsuGO_IeZy0g0kxo/edit?usp=sharing | 197 [url-allocator-shim]: https://docs.google.com/document/d/1yKlO1AO4XjpDad9rjcBOI1
5EKdAGsuGO_IeZy0g0kxo/edit?usp=sharing |
OLD | NEW |