title: Electron global variable garbage collected if renderer process closes?
body: <p>In Electron, I have my main process opening a BrowserWindow. The BrowserWindow loads one html page and then the same window eventually loads another html page.</p>
  
  <p>main.js</p>
  
  <pre><code>var mainWindow;
  global.mainState = {
    settings: {}
  }
  mainWindow = createWindow('main', {
    width: 1000,
    height: 800,
  });
  if (curState == 'load') {
    mainWindow.loadURL(`file://${__dirname}/interface/load.html`, {})
  }
  if (curState == 'login') {
    mainWindow.loadURL(`file://${__dirname}/interface/login.html`, {})
  }
  </code></pre>
  
  <p>load.html</p>
  
  <pre><code>const remote = require('electron').remote;
  var testGlobal = remote.getGlobal('mainState')
  testGlobal.settings = 'test value'
  testGlobal.settings.inner = 'test value2'
  </code></pre>
  
  <p>When main.js loads the second page (login.html), will the global variable be deleted/dereferenced? The docs say that if the renderer process dereferences a global variable then the variable will be gc'd. When I try to test this I get inconsistent results and I would just like some explanation from someone more wise than I.</p>