I've been struggling with a memory leak in firefox 56.0 with selenium 3.5.3 and gecko driver tonight found a fix that I cannot explain: if I don't use a Firefox profile the problem goes away - unfortuately that goes against all advice when using firefox.
Can anyone explain why the memory leak goes away and how I could use a profile and not suffer from a memory leak?
My code:
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
FirefoxProfile profile = new FirefoxProfile();
// Work around for FireFox not closing, fix comes from here: https://github.com/mozilla/geckodriver/issues/517
profile.setPreference("browser.tabs.remote.autostart", false);
profile.setPreference("browser.tabs.remote.autostart.1", false);
profile.setPreference("browser.tabs.remote.autostart.2", false);
profile.setPreference("browser.tabs.remote.force-enable", false);
// If I comment out this memory leak goes away
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
WebDriver driver = new FirefoxDriver(capabilities);