Global variable garbage collected if renderer process closes?


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.


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`, {})


const remote = require('electron').remote;
var testGlobal = remote.getGlobal('mainState')
testGlobal.settings = 'test value'
testGlobal.settings.inner = 'test value2'

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.