Since the Web component is a heavyweight component belonging to the core platform, the Shared Object (SO) files it depends on are approximately 200 MB in size. During page loading, the Web component performs multiple tasks including parsing of HTML, JS, and CSS, DOM tree construction, rendering, composition, display submission, and audio/video playback,
all of which require a large amount of memory. In addition, the Web component uses a large number of cache technologies to optimize user experience, which also occupies some memory. Memory consumption ranges from hundreds of MB to around 1 GB is normal.
The rendering engine Blink (derived from WebKit) of the Web component uses the V8 JavaScript engine, which implements the generational garbage collection mechanism.
Blink uses the reference counting mechanism to manage the memory of DOM nodes. When a DOM node is no longer referenced by JavaScript or CSS rules, the node is released.
The Web component uses the custom memory allocator PartitionAlloc to divide the memory into different partitions (such as the renderer and GPU process), improving allocation efficiency and reducing fragments. When the memory pressure is high, Web automatically releases the cache (such as decoded images and CSS parsing results).
Each tab page of the Web component is in an independent process. The memory reclamation mechanism is as follows:
4.1 Freezing background tab pages: Tab pages that are inactive for a long time are frozen, reducing memory and CPU usage.
4.2 Process termination: In extreme memory pressure, the system may terminate low-priority processes (such as background tab pages). If a user exits the page, the corresponding rendering process is terminated, and the system reclaims the memory of the corresponding process.
trimMemoryByPressureLevel: applications can call this API to proactively trigger the Web component kernel to release the cache, thereby optimizing the memory usage.