Skip to content
CefSwift
Esc
↑↓navigate↵open⌘Jpreview
On this page

Memory

What a CefSwift app costs in processes and memory, what the presets turn off, and the process policy.

Scripts/measure-footprint.py Examples/dist/Minimal.app
Scripts/measure-footprint.py Examples/dist/Browser.app

Footprint and launch time

Measured on an Apple M3 MacBook with 16 GB of memory, macOS 27.2.1, CEF 156.0.28, on 2026-11-12, with Scripts/measure-footprint.py. Each figure is the median of five runs that relaunch the app on an existing profile and load a static local page. Memory is the physical footprint of the app and every helper process, read five seconds after the page finished loading; it is the figure Activity Monitor shows, not resident size; 1 MB here is 2^20 bytes. Launch time runs from starting the executable to the page’s page(_:didFinishLoadWithStatus:). These runs predate the sandbox being on by default; it adds a few MB in the GPU and network processes and some tens of milliseconds at launch (design notes).

App Processes Memory Launch
CefWebView with .embedded (the Minimal example) 5 88 MB 306 ms
The same with processPolicy = .minimal 4 82 MB 284 ms
Browser example, one tab (.chrome with its own name and scheme) 7 166 MB 551 ms
For comparison: a WKWebView app 4 60 MB 284 ms
For comparison: Chrome 157, empty profile, one tab 12 286 MB –

Launch times vary by about 30 ms from run to run. The first launch after a bundle is built or signed takes 2 to 3 s longer while macOS checks its signature. A first launch on an empty profile measures within the same ranges, with up to 4 MB more memory. The Browser example starts no service host at launch: its bookmarks come from Chromium’s Bookmarks file, and its history is read when the menu bar opens. Measured on a build without the passkey and Chromium-panel code, it uses:

Browser example (measure-services.py page, median of 3) Processes Memory
At launch 6 143 MB
After typing in the address field, bookmarking the page and opening the menu bar 9 217 MB
40 s later, once the hosts have closed 6 157 MB

In the Minimal example, the 88 MB divide into the app process (39 MB), the GPU process (21 MB), the page’s renderer (16 MB), and Chromium’s network (8 MB) and storage (6 MB) services.

What the presets turn off

Configuration() .embedded .chrome
Background networking, sync, default apps, domain reliability On Off On
Component updates (services.componentUpdates), Widevine (services.protectedMedia) On Off On
Translation, preloading, hyperlink auditing, password saving, autofill On Off On
Media Router (Cast), optimization hints, Autofill server predictions On Off On
First-run and default-browser prompts On Off Off
Spare renderer (processPolicy) .automatic .onDemand .automatic
Session cookies across launches Off Off On
Frames kept for hidden pages (savedFrames) .limited .limited .limited

Every configuration also turns off Chromium’s sampling profiler (--disable-stack-profiler), which builds without Google Chrome’s branding run in the browser and some helpers for metrics that CEF never uploads, and turns on V8’s limit-based memory reducer (V8Flag_memory_reducer_limit_based), which collects a page’s heap 8 s after it loads instead of half a minute later, as Chrome for Testing does. List either feature in disabledFeatures to undo it.

Process policy

processPolicy decides how many helper processes Chromium keeps running:

var configuration = CefRuntime.Configuration.embedded
configuration.processPolicy = .minimal
Policy Saves Costs
.automatic – Chromium keeps a spare renderer running for the next new site or page.
.onDemand 1 process, 13 MB A page from a site without a renderer, and each new page, waits for one to start: a navigation to a new site takes 52 ms instead of 14 ms (local server, median of 8).
.minimal 2 processes, 19 MB As .onDemand; and the network service runs in the app’s process, so a crash in it ends the app instead of restarting the service, and code that parses network data shares the app’s memory.

The GPU process stays a process of its own in every policy, so that a GPU driver crash cannot end the app. The design notes list the switches measured and not used.

savedFrames decides how many hidden pages keep their last frame in the GPU process, so that selecting a tab again shows it at once. Each frame holds the tiles its renderer drew, about a window’s worth of pixels (18 MiB for a 1200 × 1000 window at 2x). Every preset uses .limited, at most 5 frames, the visible ones included, as Chrome ends up keeping; .automatic is Chromium’s own limit of up to 10 while memory is plentiful. A tab hidden before the last four shows a frame or two later, once its renderer has drawn again.

configuration.savedFrames = .automatic

Tuning a browser

A browser’s footprint is its tabs: each site gets a renderer, and a tab in the background keeps its memory until it is discarded. Design notes measure the Browser example beside Chrome and Helium on an 8 GB M2; there:

  • Discard background tabs. It is the one setting that changes the figure by more than a few percent: with 10 tabs, 691 MiB becomes 356 MiB once discard() has freed the 9 background tabs, and with 16 tabs, 919 MiB becomes 376 MiB, about 36 MiB a tab. Discard after a while hidden and when macOS reports memory pressure, as the Browser example’s Memory Saver does (Discarding pages); background tabs of Chromium’s tabbed windows (CefChromeWindow) are .hidden and can be discarded.
  • savedFrames decides how many hidden tabs keep their tiles in the GPU process: the default .limited held 207 MiB there with 16 tabs, Chromium’s .automatic 298 MiB (Process policy).
  • processPolicy saves a process or two, not tabs: .onDemand 11 MiB and one process with 1 tab, 38 MiB with 10; .minimal 20 MiB and two processes with 1 tab, 45 MiB with 10 (Process policy lists what each costs). Launch time did not change measurably.
  • Idle CPU with pages that run no timers: 0.5 % of one core with 1 tab, 0.9 % with 16, against 1.2 % for Chrome with 16; most of it is the browser process. With messageLoop = .external, keep energyPolicy.idleMessageLoopInterval at its default: 30 looks a second instead cost the idle browser process about 0.5 % of a core.

Was this page helpful?