User Agents

Web browsers and everyday web tech, explained

Headless Chrome Memory & CPU Savings

· 7 min read · Browsers

In this article
  1. What Headless Chrome Is and Why It Exists
  2. Where the Savings Actually Come From
  3. How to Measure Savings for Your Own Workload
  4. When Headless Saves Almost Nothing
  5. Comparing Headless Modes: New vs. Old
  6. Practical Tips to Maximize Savings
  7. Common Problems and Misconceptions
  8. Alternatives to Headless Chrome
  9. Frequently Asked Questions

Headless Chrome typically saves 30–50% memory and 20–40% CPU compared to headed Chrome for the same page load, but exact savings vary by site, hardware, and workload. These figures come from community benchmarks and engineering reports; they are not guaranteed, and some pages see almost no difference.

What Headless Chrome Is and Why It Exists

Headless Chrome is the same Chromium engine as the Chrome browser, but it runs without a visible window. It was introduced in Chrome 59 (2017) as a way to automate browser tasks on servers, CI pipelines, and cloud functions where a GUI is unnecessary. The core idea: render pages, run JavaScript, and take screenshots or extract DOM data, all without drawing pixels to a screen.

The savings come from skipping the compositing and painting pipeline that produces the on-screen image. In headed mode, the browser continuously composites layers, handles vsync, and manages windowing system resources. Headless mode skips most of that, so the CPU and GPU work is reduced. Memory savings are less direct—the browser still loads the same HTML, CSS, and JavaScript, but it may drop some buffers and caches that only exist for display.

Where the Savings Actually Come From

To understand the numbers, you need to separate memory and CPU:

  • CPU: The biggest win is eliminating compositing and rasterization. In headed mode, every frame is rasterized and composited, even if the page is static. Headless mode only does this when you request a screenshot or a PDF. For a typical page load, CPU usage drops because the browser doesn't continuously repaint.
  • Memory: The browser still allocates the same DOM, JavaScript heap, and renderer processes. However, it can skip the GPU process's texture memory and the window's backing store. On Linux, headless also avoids the X server or Wayland compositor overhead. Real-world reports often show 30–50% lower RSS (resident set size) for simple pages, but complex single-page apps may see only 10–20%.

One common misconception: headless mode does not disable JavaScript or CSS. It runs the full rendering engine, so the memory footprint of the page itself is unchanged. The savings are from the browser's own overhead, not from skipping content.

How to Measure Savings for Your Own Workload

If you want concrete numbers for your specific use case, run a controlled test. Use the same machine, the same page, and the same Chrome version. Here's a simple method:

  1. Start a headed Chrome instance with a fresh profile, load the page, wait for network idle, then record the process's RSS and CPU time (using ps on Linux or Task Manager on Windows).
  2. Close it, start headless Chrome with the same flags and profile, repeat the same steps, and record the same metrics.
  3. Run each test 3–5 times and average the results to smooth out noise.

For a more realistic measure, use Chrome's remote debugging protocol to get performance metrics like Metrics.track or use Puppeteer's page.metrics(). That gives you memory usage per renderer process, which is more accurate than system-level RSS. Remember that headless mode may use a different number of processes (e.g., no GPU process on some platforms), so compare total process group memory, not just the main process.

When Headless Saves Almost Nothing

There are cases where the savings are minimal:

  • Heavy JavaScript pages: If a page spends most of its time executing JS, the CPU usage is dominated by V8, not compositing. Headless won't reduce that.
  • Pages that force repaints: Animations or infinite scroll still trigger layout and paint, even in headless. The engine still has to compute styles and layout.
  • Memory-heavy pages: A page with a huge DOM, many images, or large WebGL contexts will still allocate the same memory. Headless only saves the display-related buffers.
  • Server-side rendering: If you're just fetching static HTML, you don't need Chrome at all—a simple HTTP client would be far more efficient.

Also, headless mode still has a GPU process on some platforms (it uses SwiftShader for software WebGL), so you may not see the GPU memory savings you'd expect.

Comparing Headless Modes: New vs. Old

Chrome introduced a new headless mode in version 112 (2023). The old headless mode (using the --headless flag) was a separate implementation that didn't share all the browser features. The new headless mode (using --headless=new) is the full browser with the windowing system removed. The new mode is closer to headed Chrome in behavior, but it also has slightly higher resource usage than the old mode because it initializes more subsystems.

If you're using the old headless mode, you might see larger savings, but you also lose features like extensions and some network stack options. For most automation tasks, the new headless mode is recommended because it's more stable and matches headed behavior. The resource savings are still there, but they're not as dramatic as the old mode's.

Practical Tips to Maximize Savings

You can reduce resource usage further with these flags and practices:

  • Use --disable-gpu to avoid the GPU process entirely (though it's already disabled in old headless).
  • Use --disable-dev-shm-usage on Linux to avoid shared memory issues in containers.
  • Limit the number of concurrent tabs or pages—each page has its own renderer process.
  • Use --js-flags="--max-old-space-size=512" to cap V8's heap if your page doesn't need much.
  • Close the browser after each task to free memory; don't keep it idle.
  • Consider using --single-process (not recommended for production) to reduce process overhead, but this can hurt stability.

Remember that these flags can break some features. For example, disabling GPU might break WebGL, but if you don't need it, you'll save memory.

Common Problems and Misconceptions

A frequent issue is that headless Chrome still uses a lot of memory in containerized environments. This is often due to the shared memory filesystem (/dev/shm) being too small by default. The browser uses shared memory for inter-process communication, and if the container limits it, Chrome may crash or consume more RSS than expected. The --disable-dev-shm-usage flag tells Chrome to use /tmp instead, which often helps.

Another misconception is that headless mode is always faster. It can be slower for some pages because it lacks the hardware acceleration that headed mode gets from the GPU. For pages that rely on GPU-accelerated CSS transforms or WebGL, headless may use more CPU as it falls back to software rendering.

Also, headless mode still downloads all resources (images, scripts, fonts) unless you explicitly block them. If you want to save bandwidth and memory, you need to intercept requests or use a tool like Puppeteer's request interception to abort unnecessary resources.

Alternatives to Headless Chrome

If you need even lower resource usage, consider these alternatives:

  • Puppeteer with Chrome for Testing: A smaller Chrome build that is still full-featured but may have a slightly lower footprint.
  • Playwright with Chromium: Similar to Puppeteer but with its own browser build that is often more minimal.
  • jsdom or Cheerio: For simple DOM scraping, these Node.js libraries are much lighter than a full browser, but they don't execute JavaScript reliably.
  • Cloud rendering services: Offload the rendering to a remote service, but that adds network latency and cost.

For production workloads, you might also consider using a browser pool that reuses a single Chrome instance across multiple requests, but that's more complex to manage.

Frequently Asked Questions

Does headless Chrome use less memory than headed Chrome for the same page?

Yes, typically it uses 30–50% less memory for simple pages, but the savings are smaller for complex web apps. The main reduction is from skipping the GPU process and the display buffers, not from the page's own memory usage.

Is headless Chrome faster than headed Chrome?

Not necessarily. It uses less CPU for compositing, but it may be slower for pages that rely on GPU acceleration. In practice, the time to load a page is often similar, but headless uses less CPU overall.

Why does my headless Chrome still use 500MB of memory?

That's normal for a modern browser. The memory is used for the JavaScript heap, DOM, and renderer processes. Headless only saves the display-related memory, which is a small fraction of the total for heavy pages.

Can I force headless Chrome to use less memory?

Yes, you can limit the V8 heap with --js-flags, disable GPU, and block unnecessary resources. But be careful: limiting memory too much can cause crashes or slow page loads.

Does headless Chrome work without a GPU?

Yes, it works without a GPU. It uses SwiftShader for software WebGL, but for most pages, you can disable GPU entirely with --disable-gpu to save resources.

Is headless Chrome safe to use on untrusted websites?

It's as safe as headed Chrome, but you should run it in a sandboxed environment (like a container) because it still executes arbitrary JavaScript. The --no-sandbox flag should be avoided unless you're in a controlled environment.