Experience
Projects
My Stack
Case studies
Contact me
Open my CV

·5 min read

The memory saver that made Figma run out of memory

I shipped a memory optimization on the evening of Sep 8, 2026, with a commit message that was proud of its numbers: idle memory from about 390 MB to about 320 MB, and about 75 MB when minimized. At 00:33 the next morning I committed again, this time to take the main flag out. The saving was real. It was also the reason heavy web apps were dying.

Project
Light Browser
Date
Sep 2026
Stack
C++, Win32, WebView2
Commit
7f0ffa2

What broke

Light Browser puts a thin Win32 shell around Microsoft Edge WebView2, so memory is mostly Chromium's, and the only control I have is the set of command-line arguments I pass when the engine starts. A small footprint was a goal of the project, so I reached for the biggest lever on the list.

In c8cd03e (Sep 8) I added these arguments:

cpp
L"--enable-low-end-device-mode"
L" --renderer-process-limit=4"
L" --process-per-site"

The commit message reports the result: "Idle ~390MB -> ~320MB; minimized drops to ~75MB." Minimizing also dropped every tab to the low memory target and suspended the background ones.

The cost showed up in heavy apps. The renderer process of a page like Figma would exit with an out-of-memory status. The comment I wrote the next day names the apps: Figma and Google Docs. The browser showed the generic "Aw, snap" page, which told the user nothing about why.

What the code showed

Two separate things were going wrong, and one of them was my own code.

The first was the flag. Chromium's low-end-device mode is designed for phones and tiny machines. Among other things, it halves the V8 heap limits. A large design tool or document editor holds a lot of JavaScript state, and with half the headroom it can run out. The flag reads like "use less memory". What it does is "allow less memory", and an app that needs more than the allowance does not slow down, it dies.

The second was in the RAM-limit cascade I had written on top. When memory is over the user's limit, the cascade freezes background tabs first, then unloads the least recently used ones. When only the current page is left, it asked the engine to lower that page's memory target and trimmed working sets, and it did that on every sample. Squeezing a heavy page repeatedly can push its renderer over the edge by itself, no flag required.

Looking at what I had, the browser could not tell me any of this. The failure handler treated every dead renderer the same way. So the first step of the fix was not removing the flag, it was making the failure legible.

cpp
case COREWEBVIEW2_PROCESS_FAILED_REASON_OUT_OF_MEMORY: why = L"out of memory"; break;
case COREWEBVIEW2_PROCESS_FAILED_REASON_CRASHED:       why = L"crashed"; break;
...
why += L" (exit code " + std::to_wstring(code) + L")";

WebView2 exposes the reason and exit code through ICoreWebView2ProcessFailedEventArgs2. I read both and store them on the tab as crashReason.

The fix

7f0ffa2 (Sep 9, 2026) did four things.

It removed the flag and left a comment in the code explaining why, so I would not add it back later:

cpp
// Lighter footprint: capped renderer count, a real disk cache, no unused background
// services, and Cloudflare DNS over HTTPS. (Chromium's low-end-device mode is NOT
// used: it halves V8 heap limits and makes heavy apps like Figma die of OOM.)
L"--renderer-process-limit=16 --process-per-site"

It raised the renderer process limit from 4 to 16. Capping the process count keeps a lid on RAM without touching heap limits.

It throttled the cascade. When no tab is left to freeze or unload, the squeeze on the active page now happens at most once every 30 seconds:

cpp
ULONGLONG now = GetTickCount64();
if (now - lastActiveSqueeze_ < 30'000) return;
lastActiveSqueeze_ = now;
SetMemoryTarget(Active(), COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL_LOW);
TrimWorkingSets();

And it made the crash page honest. For an out-of-memory exit it now reads "Reason: out of memory (exit code N)", followed by a hint that the page needed more memory than was available and that raising the RAM limit in Settings or closing other tabs may help. The same commit added the equivalent reason for the Linux shell, using WebKitGTK's own termination reasons.

removed in 7f0ffa2throttled to 30 sreason and exit codeLow-end mode flaghalves V8 heap limitsRAM cascadesqueezes the last pageRenderer OOM exitFigma, Google DocsCrash pagenow shows the reason
Figure 1. The low-end flag and the cascade were two separate ways to starve a heavy page. The fix removes one and rate-limits the other.

A neighbor commit on the same day, a8cb57b (Sep 8), is worth a line. My memory number came from hand-counting non-shared pages, which undercounted and was denied on sandboxed renderers. I replaced it with PrivateWorkingSetSize, the field Task Manager shows. A memory feature is only as good as its metric, and mine had been wrong in a flattering direction.

What I would do differently

I would test the optimization on the heaviest page I use, before committing it. The 390 to 320 MB figure came from an idle browser. An idle browser is the easiest case, and the one that tells you the least about whether a feature is safe. A heavy page open in one tab for a few minutes is a better test, and it would have shown the exit.

I would also have read what the flag does before enabling it. "Low end device" is not a synonym for "efficient". It is a different profile with different limits, and a profile chosen for a phone does not fit a desktop browser that people use for design tools.

I will not claim a number for what the removal cost in memory. I did not benchmark the browser after this change, and I do not have an idle figure to quote for the new flags. The commit message and the code are the evidence here, and they say what was removed and why, not what the browser now uses.

Where this fits

This story is one of several in building Light Browser, a small C++ shell on the system web engine where most of the hard problems came from respecting the limits of the engine underneath. The memory manager, the other crashes and the rest of the design are in the full Light Browser case study.

The full project story shows how the memory manager, blocker and installer fit together, and what went wrong along the way.

Read the full case study

#cpp#webview2#chromium#memory#debugging

Keep reading

Have a project in mind?