<ul dir="auto">
<li>Electron version: Tested <code class="notranslate">1.6.12</code> and <code class="notranslate">1.7.5</code></li>
<li>Operating system: At least Linux</li>
</ul>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">When calling <code class="notranslate">fork</code> from the <code class="notranslate">child_process</code> module, I'd expect the <code class="notranslate">execArgv</code> argument to work as it does when calling <code class="notranslate">fork</code> from a node script.</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">Flags such as <code class="notranslate">--expose-gc</code> and <code class="notranslate">--max-old-space-size</code> do not work. In the child process, <code class="notranslate">process.execArgv</code> contains the arguments as expected.</p>
<h3 dir="auto">How to reproduce</h3>
<p dir="auto"><a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/danielscottjames/electron-quick-start/commit/3d8e548d502d69be24d535de3038d2a942557c94/hovercard" href="https://github.com/danielscottjames/electron-quick-start/commit/3d8e548d502d69be24d535de3038d2a942557c94">danielscottjames/electron-quick-start@<tt>3d8e548</tt></a></p>
<p dir="auto">Running the example electron program, either packaged or not, results in:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="process.execArgv:--expose-gc
expose.gc is not defined"><pre class="notranslate"><code class="notranslate">process.execArgv:--expose-gc
expose.gc is not defined
</code></pre></div>
<p dir="auto">Running the <code class="notranslate">mainnode.js</code> script like <code class="notranslate">node mainnode.js</code> results in:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="process.execArgv:--expose-gc
expose.gc is defined"><pre class="notranslate"><code class="notranslate">process.execArgv:--expose-gc
expose.gc is defined
</code></pre></div>
<p dir="auto">as expected.</p>
<ul dir="auto">
<li>Electron version: 1.6.10</li>
</ul>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">I expect <code class="notranslate">--max_old_space_size</code> to work when electron is run as node. This was initially discussed <a href="https://github.com/electron/electron/issues/2056#issuecomment-306565476" data-hovercard-type="issue" data-hovercard-url="/electron/electron/issues/2056/hovercard">here</a> (Sorry for the double post in case you follow-up on comments in closed issues)</p>
<h3 dir="auto">How to reproduce</h3>
<ul dir="auto">
<li>Have a program that keeps allocating memory (see below, save it as <code class="notranslate">big.js</code>)</li>
<li>Run it via <code class="notranslate">./node_modules/electron/dist/Electron.app/Contents/MacOS/Electron --js-flags="--max_old_space_size=128" ~/Desktop/big.js</code> and see that the last message is <code class="notranslate">heapTotal: 139</code></li>
<li>Now run as node via <code class="notranslate">env ELECTRON_RUN_AS_NODE=true ./node_modules/electron/dist/Electron.app/Contents/MacOS/Electron --max_old_space_size=128 ~/Desktop/big.js</code> and see that the last message is <code class="notranslate">heapTotal: 1504</code></li>
<li><g-emoji class="g-emoji" alias="bug" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41b.png">🐛</g-emoji> The <code class="notranslate">max_old_space_size</code>-flag has no effect when running as node, the limit is always ~1.5GB and cannot be lowered nor increased.</li>
</ul>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="let all = [];
let big = [];
all.push(big);
for (let i = 0; i &lt; 1000000000; i++) {
    let newLen = big.push(Math.random());
    if (newLen % 500000 === 0) {
        big = [];
        all.push(big);
        console.log('all.length: ' + all.length);
        console.log('heapTotal: ' + Math.round(process.memoryUsage().heapTotal / 1e6));
    }
}

console.log(all.length);
"><pre class="notranslate"><span class="pl-k">let</span> <span class="pl-s1">all</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-s1">big</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-s1">all</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span><span class="pl-s1">big</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">let</span> <span class="pl-s1">i</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span> <span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> <span class="pl-c1">1000000000</span><span class="pl-kos">;</span> <span class="pl-s1">i</span><span class="pl-c1">++</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">let</span> <span class="pl-s1">newLen</span> <span class="pl-c1">=</span> <span class="pl-s1">big</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span><span class="pl-v">Math</span><span class="pl-kos">.</span><span class="pl-en">random</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">newLen</span> <span class="pl-c1">%</span> <span class="pl-c1">500000</span> <span class="pl-c1">===</span> <span class="pl-c1">0</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-s1">big</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
        <span class="pl-s1">all</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span><span class="pl-s1">big</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'all.length: '</span> <span class="pl-c1">+</span> <span class="pl-s1">all</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'heapTotal: '</span> <span class="pl-c1">+</span> <span class="pl-v">Math</span><span class="pl-kos">.</span><span class="pl-en">round</span><span class="pl-kos">(</span><span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-en">memoryUsage</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-c1">heapTotal</span> <span class="pl-c1">/</span> <span class="pl-c1">1e6</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">all</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>