blob: ebe653533d3ecbef36d1ae1d8eb8b2f421ce847f [file] [log] [blame] [view]
hjd0304f112016-11-14 22:36:531# Memory Usage in CC
2
3This document gives an overview of memory usage in the CC component, as well as
4information on how to analyze that memory.
5
6[TOC]
7
8## Types of Memory in Use
9
10CC uses a number of types of memory:
11
121. Malloc Memory - Standard system memory used for all manner of objects in CC.
132. 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.
193. 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.
234. 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
28Memory-infra tracing will grab dumps of CC memory in several categories.
29
30### CC Category
31
32The CC category contains resource allocations made by ResourceProvider. All
33resource allocations are enumerated under cc/resource_memory. A subset of
34resources are used as tile memory, and are also enumerated under cc/tile_memory.
35For resources that appear in both cc/tile_memory and cc/resource_memory, the
36size will be attributed to cc/tile_memory (effective_size of cc/resource_memory
37will not include these resources).
38
39If the one-copy tile update path is in use, the cc category will also enumerate
40staging resources used as intermediates when drawing tiles. These resources are
41like tile_memory, in that they are shared with cc/resource_memory.
42
43Note that depending on the path being used, CC memory may be either shared
44memory or GPU memory:
45
primianob48bcd62017-04-03 09:45:3446```
hjd0304f112016-11-14 22:36:5347Path | Tile Memory Type | Staging Memory Type
48-------------|-------------------------------------------
49Bitmap | Shared Memory | N/A
50One Copy | GPU Memory | Shared Memory
51Zero Copy | GPU or Shared Memory | N/A
52GPU | GPU Memory | N/A
primianob48bcd62017-04-03 09:45:3453```
hjd0304f112016-11-14 22:36:5354
55Note that these values can be determined from a memory-infra dump. For a given
56resource, hover over the small green arrow next to it's "size". This will show
57the other allocations that this resource is aliased with. If you see an
58allocation in the GPU process, the memory is generally GPU memory. Otherwise,
59the resource is typically Shared Memory.
60
61Tile and Staging memory managers are set up to evict any resource not used
62within 1s.
63
64### GPU Category
65
66This category lists the memory allocations needed to support CC's GPU path.
67Despite the name, the data in this category (within a Renderer process) is not
68GPU memory but Shared Memory.
69
70Allocations tracked here include GL command buffer support allocations such as:
71
721. Command Buffer Memory - memory used to send commands across the GL command
73 buffer. This is backed by Shared Memory.
742. Mapped Memory - memory used in certain image upload paths to share data
75 with the GPU process. This is backed by Shared Memory.
763. Transfer Buffer Memory - memory used to transfer data to the GPU - used in
77 different paths than mapped memory. Also backed by Shared Memory.
78
79### Discardable Category
80
81Cached images make use of Discardable memory. These allocations are managed by
82Skia and a better summary of these allocations can likely be found in the Skia
83category.
84
85### Malloc Category
86
87The malloc category shows a summary of all memory allocated through malloc.
88
89Currently the information here is not granular enough to be useful, and a
90good project would be to track down and instrument any large pools of memory
91using malloc.
92
93Some Skia caches also make use of malloc memory. For these allocations, a better
94summary can be seen in the Skia category.
95
96### Skia Category
97
98The Skia category shows all resources used by the Skia rendering system. These
99can be divided into a few subcategories. skia/gpu_resources/* includes all
100resources using GPU memory. All other categories draw from either Shared or
101malloc memory. To determine which type of memory a resource is using, hover
102over the green arrow next to its size. This will show the other allocations
103which the resource is aliased with.
104
105## Other Areas of Interest
106
107Many of the allocations under CC are aliased with memory in the Browser or GPU
108process. When investigating CC memory it may be worth looking at the following
109external categories:
110
1111. GPU Process / GPU Category - All GPU resources allocated by CC have a
112 counterpart in the GPU/GPU category. This includes GL Textures, buffers, and
113 other GPU backed objects such as Native GPU Memory Buffers.
1142. Browser Process / GpuMemoryBuffer Category - Resources backed by Shared
115 Memory GpuMemoryBuffers are allocated by the browser and will be tracked
116 in this category.
1173. Browser Process / SharedMemory Category - Resources backed by Bitmap and
118 Shared Memory GpuMemoryBuffer objects are allocated by the browser and will
119 also tracked in this category.
120
121## Memory TODOs
122
123The following areas have insufficient memory instrumentation.
124
1251. DisplayLists - DisplayLists can be quite large and are currently
126 un-instrumented. These use malloc memory and currently contribute to
xiaoyin.l1003c0b2016-12-06 02:51:17127 malloc/allocated_objects/<unspecified>. [BUG](https://crbug.com/567465)