42

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
  • 6,953
  • 7
  • 59
  • 105
mitchellt
  • 814
  • 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

3 Answers3

31

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,425
  • 16
  • 19
  • 12
    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
  • On Windows, that's `chrome.exe --js-flags="--max_old_space_size=1024"`. – Holistic Developer Mar 15 '21 at 21:35
15

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
  • 20,117
  • 15
  • 137
  • 145
  • 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
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
  • 11,258
  • 13
  • 77
  • 141
  • 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