I've been running HtmlUnit via Selenium in 16 threads for hours and noticed the memory is accumulating over time.
Destroying the driver is one solution I am looking into, but so far it seems like most of the leakage is from javascript.
Is there a clean way to purge a driver or HtmlUnit itself to close all active pages, terminating and cleaning up any related javascript objects as well?
The workaround is to remember when a driver was instantiated and if it has been alive for long enough, save the cookies, destroy the driver, spin up a new one and inject the cookies back. But that is a lot of work just to do cleanup.