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 |
11 `DiscardableMemory` which, similarly to the above, have their own page-level | 11 `DiscardableMemory` which, similarly to the above, have their own page-level |
12 memory management. | 12 memory management. |
13 | 13 |
14 Background | 14 Background |
15 ---------- | 15 ---------- |
16 The `allocator` target defines at compile-time the platform-specific choice of | 16 The `allocator` target defines at compile-time the platform-specific choice of |
17 the allocator and extra-hooks which services calls to malloc/new. The relevant | 17 the allocator and extra-hooks which services calls to malloc/new. The relevant |
18 build-time flags involved are `use_allocator` and `win_use_allocator_shim`. | 18 build-time flags involved are `use_allocator` and `use_allocator_shim`. |
19 | 19 |
20 The default choices are as follows: | 20 The default choices are as follows: |
21 | 21 |
22 **Windows** | 22 **Windows** |
23 `use_allocator: winheap`, the default Windows heap. | 23 `use_allocator: winheap`, the default Windows heap. |
24 Additionally, `static_library` (i.e. non-component) builds have a shim | 24 Additionally, `static_library` (i.e. non-component) builds have a shim |
25 layer wrapping malloc/new, which is controlled by `win_use_allocator_shim`. | 25 layer wrapping malloc/new, which is controlled by `use_allocator_shim`. |
26 The shim layer provides extra security features, such as preventing large | 26 The shim layer provides extra security features, such as preventing large |
27 allocations that can hit signed vs. unsigned bugs in third_party code. | 27 allocations that can hit signed vs. unsigned bugs in third_party code. |
28 | 28 |
29 **Linux Desktop / CrOS** | 29 **Linux Desktop / CrOS** |
30 `use_allocator: tcmalloc`, a forked copy of tcmalloc which resides in | 30 `use_allocator: tcmalloc`, a forked copy of tcmalloc which resides in |
31 `third_party/tcmalloc/chromium`. Setting `use_allocator: none` causes the build | 31 `third_party/tcmalloc/chromium`. Setting `use_allocator: none` causes the build |
32 to fall back to the system (Glibc) symbols. | 32 to fall back to the system (Glibc) symbols. |
33 | 33 |
34 **Android** | 34 **Android** |
35 `use_allocator: none`, always use the allocator symbols coming from Android's | 35 `use_allocator: none`, always use the allocator symbols coming from Android's |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 Related links | 188 Related links |
189 ------------- | 189 ------------- |
190 - [Unified allocator shim doc - Feb 2016][url-allocator-shim] | 190 - [Unified allocator shim doc - Feb 2016][url-allocator-shim] |
191 - [Allocator cleanup doc - Jan 2016][url-allocator-cleanup] | 191 - [Allocator cleanup doc - Jan 2016][url-allocator-cleanup] |
192 - [Proposal to use PartitionAlloc as default allocator](https://crbug.com/339604
) | 192 - [Proposal to use PartitionAlloc as default allocator](https://crbug.com/339604
) |
193 - [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) |
194 | 194 |
195 [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 |
196 [url-memory-infra-heap-profiler]: /docs/memory-infra/heap_profiler.md | 196 [url-memory-infra-heap-profiler]: /docs/memory-infra/heap_profiler.md |
197 [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 |