OLD | NEW |
1 # Memory Usage in CC | 1 This document has moved to [//docs/memory-infra/probe-cc.md](/docs/memory-infra/
probe-cc.md). |
2 | |
3 This document gives an overview of memory usage in the CC component, as well as | |
4 information on how to analyze that memory. | |
5 | |
6 [TOC] | |
7 | |
8 ## Types of Memory in Use | |
9 | |
10 CC uses a number of types of memory: | |
11 | |
12 1. Malloc Memory - Standard system memory used for all manner of objects in CC. | |
13 2. Discardable Memory - Memory allocated by the discardable memory system. | |
14 Designed to be freeable by the system at any time (under memory pressure). | |
15 In most cases, only pinned discardable memory should be considered to | |
16 have a cost; however, the implementation of discardable memory is platform | |
17 dependent, and on certain platforms unpinned memory can contribute to | |
18 memory pressure to some degree. | |
19 3. Shared Memory - Memory which is allocated by the Browser and can safely | |
20 be transferred between processes. This memory is allocated by the browser | |
21 but may count against a renderer process depending on who logically "owns" | |
22 the memory. | |
23 4. GPU Memory - Memory which is allocated on the GPU and typically does not | |
24 count against system memory. This mainly includes OpenGL objects. | |
25 | |
26 ## Categories Of Memory | |
27 | |
28 Memory-infra tracing will grab dumps of CC memory in several categories. | |
29 | |
30 ### CC Category | |
31 | |
32 The CC category contains resource allocations made by ResourceProvider. All | |
33 resource allocations are enumerated under cc/resource_memory. A subset of | |
34 resources are used as tile memory, and are also enumerated under cc/tile_memory. | |
35 For resources that appear in both cc/tile_memory and cc/resource_memory, the | |
36 size will be attributed to cc/tile_memory (effective_size of cc/resource_memory | |
37 will not include these resources). | |
38 | |
39 If the one-copy tile update path is in use, the cc category will also enumerate | |
40 staging resources used as intermediates when drawing tiles. These resources are | |
41 like tile_memory, in that they are shared with cc/resource_memory. | |
42 | |
43 Note that depending on the path being used, CC memory may be either shared | |
44 memory or GPU memory: | |
45 | |
46 Path | Tile Memory Type | Staging Memory Type | |
47 -------------|------------------------------------------- | |
48 Bitmap | Shared Memory | N/A | |
49 One Copy | GPU Memory | Shared Memory | |
50 Zero Copy | GPU or Shared Memory | N/A | |
51 GPU | GPU Memory | N/A | |
52 | |
53 Note that these values can be determined from a memory-infra dump. For a given | |
54 resource, hover over the small green arrow next to it's "size". This will show | |
55 the other allocations that this resource is aliased with. If you see an | |
56 allocation in the GPU process, the memory is generally GPU memory. Otherwise, | |
57 the resource is typically Shared Memory. | |
58 | |
59 Tile and Staging memory managers are set up to evict any resource not used | |
60 within 1s. | |
61 | |
62 ### GPU Category | |
63 | |
64 This category lists the memory allocations needed to support CC's GPU path. | |
65 Despite the name, the data in this category (within a Renderer process) is not | |
66 GPU memory but Shared Memory. | |
67 | |
68 Allocations tracked here include GL command buffer support allocations such as: | |
69 | |
70 1. Command Buffer Memory - memory used to send commands across the GL command | |
71 buffer. This is backed by Shared Memory. | |
72 2. Mapped Memory - memory used in certain image upload paths to share data | |
73 with the GPU process. This is backed by Shared Memory. | |
74 3. Transfer Buffer Memory - memory used to transfer data to the GPU - used in | |
75 different paths than mapped memory. Also backed by Shared Memory. | |
76 | |
77 ### Discardable Category | |
78 | |
79 Cached images make use of Discardable memory. These allocations are managed by | |
80 Skia and a better summary of these allocations can likely be found in the Skia | |
81 category. | |
82 | |
83 ### Malloc Category | |
84 | |
85 The malloc category shows a summary of all memory allocated through malloc. | |
86 | |
87 Currently the information here is not granular enough to be useful, and a | |
88 good project would be to track down and instrument any large pools of memory | |
89 using malloc. | |
90 | |
91 Some Skia caches also make use of malloc memory. For these allocations, a better | |
92 summary can be seen in the Skia category. | |
93 | |
94 ### Skia Category | |
95 | |
96 The Skia category shows all resources used by the Skia rendering system. These | |
97 can be divided into a few subcategories. skia/gpu_resources/* includes all | |
98 resources using GPU memory. All other categories draw from either Shared or | |
99 malloc memory. To determine which type of memory a resource is using, hover | |
100 over the green arrow next to its size. This will show the other allocations | |
101 which the resource is aliased with. | |
102 | |
103 ## Other Areas of Interest | |
104 | |
105 Many of the allocations under CC are aliased with memory in the Browser or GPU | |
106 process. When investigating CC memory it may be worth looking at the following | |
107 external categories: | |
108 | |
109 1. GPU Process / GPU Category - All GPU resources allocated by CC have a | |
110 counterpart in the GPU/GPU category. This includes GL Textures, buffers, and | |
111 other GPU backed objects such as Native GPU Memory Buffers. | |
112 2. Browser Process / GpuMemoryBuffer Category - Resources backed by Shared | |
113 Memory GpuMemoryBuffers are allocated by the browser and will be tracked | |
114 in this category. | |
115 3. Browser Process / SharedMemory Category - Resources backed by Bitmap and | |
116 Shared Memory GpuMemoryBuffer objects are allocated by the browser and will | |
117 also tracked in this category. | |
118 | |
119 ## Memory TODOs | |
120 | |
121 The following areas have insufficient memory instrumentation. | |
122 | |
123 1. DisplayLists - DisplayLists can be quite large and are currently | |
124 un-instrumented. These use malloc memory and currently contribute to | |
125 malloc/allocated_objects/<unspecified>. [BUG](crbug.com/567465) | |
OLD | NEW |