I have a java application that create 4 selenium drivers.
WebDrivers are created in the following way
FirefoxOptions options = new FirefoxOptions();
options.addArguments("-headless");
options.addPreference("gfx.webrender.all", false);
options.addPreference("gfx.webrender.enabled", false);
options.addPreference("pdfjs.disabled", true);
options.addPreference("layers.acceleration.disabled", true);
options.addPreference("extensions.enabled", false);
options.addPreference("dom.webnotifications.enabled", false);
options.addPreference("media.autoplay.enabled", false);
options.addPreference("dom.ipc.processCount", 1);
options.addPreference("media.peerconnection.enabled", false);
options.addPreference("geo.enabled", false);
WebDriver f = new FirefoxDriver(options);
I run a periodically task (runnable) created with
ScheduledExecutorService scheduler1 = Executors.newScheduledThreadPool(1);
where I add and remove tabs on promise (when a window is closed an driver.close is performed and when added the logic add new on the driver where there are fewer tabs)
I run also another periodically task (runnable) to process all tabs driver with a multithreading strategy with a static class variable. I I have to do a foreach driver.getWindowHandles() and get html page content to do my logic.
ExecutorService executorService = Executors.newFixedThreadPool(4);
With that approach I can allocate 1 thread per each WebDriver to have more execution time performance and reuse always the same ExecutorService.
So in resume, all drivers instance are initialising once and never changed (closed or re-initialised) because the application should run 24/7 .
When application starts and the first two hours the RAM is normally and stable (8GB~10GB) but, slowly and hour after hour, the RAM is increasing and goes close to the limite VPS RAM resource (24GB).
What could be generating this increase in RAM?
What I can do to maintain the RAM stable?
It's a good idea manage some Garbage Collector or JVM heap management ?
Regards,