<ul dir="auto">
<li>Electron version: v0.36.8</li>
<li>Operating system: Linux olimp 3.2.0-4-amd64 <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="14015029" data-permission-text="Title is private" data-url="https://github.com/electron/electron/issues/1" data-hovercard-type="issue" data-hovercard-url="/electron/electron/issues/1/hovercard" href="https://github.com/electron/electron/issues/1">#1</a> SMP Debian 3.2.68-1+deb7u3 x86_64 GNU/Linux</li>
</ul>
<p dir="auto"><a href="http://electron.atom.io/docs/v0.36.8/api/browser-window/#wincapturepagerect-callback" rel="nofollow">http://electron.atom.io/docs/v0.36.8/api/browser-window/#wincapturepagerect-callback</a></p>
<p dir="auto">My app takes periodically screenshot every one second. After one hour electron memory usage is 6GB and then it crashes</p>
<p dir="auto">I capture the mainWindows screen every 40ms to stream it to another computer. But the memory consumption rises and rises and at about 15 GB it slows down the webpage.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var handleScreenCapture = function(image) {
            image = null;
            setTimeout(screenTick, 40);
    }

    var screenTick = function() {
            mainWindow.capturePage({x:0,y:0, width:1920,height:360}, handleScreenCapture);
    }


    mainWindow.webContents.on('did-finish-load', function() {
        setTimeout(screenTick, 40);
    });"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-en">handleScreenCapture</span> <span class="pl-c1">=</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-s1">image</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            <span class="pl-s1">image</span> <span class="pl-c1">=</span> <span class="pl-c1">null</span><span class="pl-kos">;</span>
            <span class="pl-en">setTimeout</span><span class="pl-kos">(</span><span class="pl-s1">screenTick</span><span class="pl-kos">,</span> <span class="pl-c1">40</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>

    <span class="pl-k">var</span> <span class="pl-en">screenTick</span> <span class="pl-c1">=</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            <span class="pl-s1">mainWindow</span><span class="pl-kos">.</span><span class="pl-en">capturePage</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-c1">x</span>:<span class="pl-c1">0</span><span class="pl-kos">,</span><span class="pl-c1">y</span>:<span class="pl-c1">0</span><span class="pl-kos">,</span> <span class="pl-c1">width</span>:<span class="pl-c1">1920</span><span class="pl-kos">,</span><span class="pl-c1">height</span>:<span class="pl-c1">360</span><span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-en">handleScreenCapture</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>


    <span class="pl-s1">mainWindow</span><span class="pl-kos">.</span><span class="pl-c1">webContents</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'did-finish-load'</span><span class="pl-kos">,</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-en">setTimeout</span><span class="pl-kos">(</span><span class="pl-en">screenTick</span><span class="pl-kos">,</span> <span class="pl-c1">40</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></pre></div>
<p dir="auto">Is there a fix for that. Is it possible to garbage collect manually?</p>
<p dir="auto">Thanks<br>
Christoph</p>