56

I am running several thousand https clients through chrome on one tab, I seem to be hitting a limit in the browser, when I check task manager the chrome process for that tab is using a whopping 897MB so I am assuming there is some sort of limit (900MB~).

Are there any chrome wizards around that could explain this? Also it would be ideal if I could increase the max limit so I am able to run more clients through a single tab.

Kromster
  • 7,181
  • 7
  • 63
  • 111
mitchellt
  • 954
  • 4
  • 13
  • 26
  • 1
    I think it has to something with chrome being 32bit. Downloading the beta that is 64bit seems to allow tabs to go up to ~1.5-1.7 gig. – Henrik Karlsson Mar 30 '15 at 16:58

4 Answers4

38

By default v8 has a memory limit of 512MB on 32-bit systems, and 1.4GB on 64-bit systems. The limit can be raised by setting --max_old_space_size to a maximum of 1024 (1 GB) on 32-bit and 4096 (4GB) on 64-bit. You should be able to set this parameter when launching Chrome from a shell in Linux, or as an argument to the shortcut path in Windows.

Mihai Tomescu
  • 1,525
  • 16
  • 21
  • 13
    You actually have to use the `--js-flags` option to pass flags to the V8 engine: `open /Applications/Google\ Chrome.app --args --js-flags="--max_old_space_size=8192"` – Luc Nov 13 '16 at 20:46
  • @Luc is there any way to verify which syntax is correct? Also, is "--args" documented someplace? i don't see it here https://peter.sh/experiments/chromium-command-line-switches/ – johny why Aug 10 '18 at 01:49
  • 1
    @johnywhy `--args` is how to pass flags from OSX's `open` command to the process being opened: https://brettterpstra.com/2014/08/06/shell-tricks-the-os-x-open-command/#other-handiness – ericsoco Apr 03 '19 at 16:12
  • @ericsoco Cool. Would be helpful if Luc mentioned "Mac" – johny why Apr 14 '19 at 08:42
  • Where is the source for the number of 1.4GB limit for 64bit systems? In Google Chrome 64bit it seems to be possible to use >1.4. GB without the flag. window.performance.memory MemoryInfo {totalJSHeapSize: 1689589628, usedJSHeapSize: 1656606844, jsHeapSizeLimit: 4294705152} – Stefan Dec 08 '20 at 15:42
  • 2
    @Stefan true the limit on x64 is outdated. According to the flags defined in https://github.com/v8/v8/blob/0cad8a53c8aa7d072419a42c3d26745386210ef9/src/flags/flag-definitions.h#L929, `max_old_space_size` now defaults to 0. I tested a default node v12.20.0 installation and it fails to allocate at around 2GB. Btw I was just referring to the max memory per tab/v8 process not the total usage across all tabs which is the output of `window.performance.memory`. – Mihai Tomescu Dec 10 '20 at 15:09
  • [there is no 4Gb per tab limitation](https://bugs.chromium.org/p/chromium/issues/detail?id=1081316) – malat Jan 29 '21 at 10:35
  • 2
    On Windows, that's `chrome.exe --js-flags="--max_old_space_size=1024"`. – Holistic Developer Mar 15 '21 at 21:35
19

Aggregated answer based on Mihai Tomescu's answer and other resources:

  1. Maximum memory per tab seems to be about 1.8GB when running a x64 Windows OS, according to this answer

  2. Increasing tab memory works fine by changing Chrome link address from "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" to "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --max_old_space_size=4096

The difference can be quickly tested using this huge image which will crash Chrome using default memory settings (Google Chrome ran out of memory while trying to display this webpage), but will render fine after increasing the memory limit.

Community
  • 1
  • 1
Alexei - check Codidact
  • 22,016
  • 16
  • 145
  • 164
  • 2
    Here is how to open the chrome with a different user add flag ```--profile-directory="Profile 7"``` you can get the profile directory by going to ```chrome://version``` and locate the **profile path** code `"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --max_old_space_size=4096 --profile-directory="Profile 7"` – Salman Nov 21 '19 at 18:22
  • 2
    did something change with the "huge image"? I just opened it and didn't increase the memory. – Angela P Apr 09 '21 at 16:20
  • 1
    @AngelaP Yes, it is no longer visible on their website and you have to download the big version. I will try to replace this with a relevant resource. – Alexei - check Codidact Apr 09 '21 at 17:09
8

It seems --max_old_space_size does not work anymore. I tested on Ubuntu 22.04 (Version 106.0.5249.119) where it did nothing, and I found this thread on Google Support saying it was removed in Chrome 104.

On Ubuntu 23.04, it still does not work but the limit seems to be above 4Gio at least on my laptop.

Here is how to check it for yourself:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="Author" content="Laurent LYAUDET">
  <meta name="Publisher" content="Laurent LYAUDET">
  <meta name="Description"
    content="Check if Chrome still limits tab memory">
  <meta name="Keywords"
    content="debug Chrome">
  <title>All your memory are belong to us! XD</title>
</head>
<body>
  <h1>Check if Chrome still limits tab memory</h1>
  <p>
  Step 1: Open Chrome with command line in incognito mode
  to avoid messing with your profile (adapt this line to your OS):
  <pre>
  /usr/bin/google-chrome-stable --incognito --max_old_space_size=4096
  </pre>
  </p>
  <p>
  Step 2: Open Chrome Task Manager to check your memory (Menu > More Tools > Task manager)
  </p>
  <p>
  Step 3: Look at how much RAM used it crashes.
  </p>
  <p>
  Step 4: Repeat from step 1 with --max_old_space_size=1024.
  Currently "Version 112.0.5615.165 (Build officiel) (64 bits)",
  max_old_space_size seems to do nothing.
  Webpage loads fine with both if fine_tune_me = 400000.
  Webpage crashes with both if fine_tune_me = 1000000.
  </p>
  <script>
  // let fine_tune_me = 400000; // This value should be ok if you have enough RAM.
  let fine_tune_me = 1000000; // This value should crash.
  document.addEventListener("DOMContentLoaded", function () {
    for(let i = 0; i < fine_tune_me; ++i){
      let myTextArea = document.createElement("textarea");
      myTextArea.textContent = "All your memory are belong to us!";
      document.body.appendChild(myTextArea);
    }  
  });
  </script>
</body>
</html>
Laurent Lyaudet
  • 630
  • 8
  • 16
1

I don't believe electron has a hard limit of 4gb. That may be its default, but I've been able to get to 16gb by doing the following in main.js:

  const { app } = require('electron');
  app.commandLine.appendSwitch('js-flags', '--max-old-space-size=16384');

Unfortunately no such switch exists for the Chrome browser.

Reference:

malat
  • 12,152
  • 13
  • 89
  • 158
  • This doesn't work for me. At least, it doesn't raise the `jsHeapSizeLimit` for the renderer process. I'm able to reduce the heap size limit with this command, but can't increase it. – z80crew Jul 28 '21 at 09:47