title: Forcing garbage collection in Google Chrome
body: <p>We are developing a single-page web app with <a href="http://www.zkoss.org/" rel="noreferrer" title="Zkoss">ZK</a> which constantly communicates with server and updates parts of its screens. Updating can be as frequent as 1s. During these updates, references to large ammounts of <em>JS</em> objects are lost and those objects have to be cleaned by garbage collector eventually.</p>
  
  <p>As far as we've figured out, Chrome only runs its garbage collector on inactive tabs. This is a problem for us, because the app's tab is usually active and almost never refreshed, thus <em>JS</em> objects never get collected. If left active for enough time, the tab eventually crashes (<em>Aww Snap</em> message).</p>
  
  <p>We need to initiate garbage collection manually. So far we've tried running Chrome with <code>--js-flags="--expose-gc"</code> and running <code>gc()</code>, but it throws an exception:</p>
  
  <pre><code>ReferenceError: gc is not defined
  </code></pre>
  
  <p>This doesn't happen on Firefox -- memory usage is more or less a constant.</p>
  
  <p>Force refreshing the page is not an option.</p>
  
  <p>We would be grateful for any and all suggestions.</p>
  
  <p><strong>EDIT</strong>: we've tried running <code>window.gc()</code> and <code>gc()</code> both on Chrome versions <code>23.0.1271.97 m</code> and <code>25.0.1364.2 dev-m</code></p>