TestFX icon indicating copy to clipboard operation
TestFX copied to clipboard

Remove Application from ParametersImpl

Open qtran opened this issue 6 years ago • 1 comments

After we ported our tests from 3.x to 4.0.15 we are running sometimes into memory problems. I think the problem is that the Application is registered each time in ParametersImpl and is never removed. So the GC can never remove the test classes from the memory. Our current workaround is to remove the Application via Reflection from ParametersImpl:

public static void clearApplication() {
	try {
		final Field f = ParametersImpl.class.getDeclaredField("params");
		f.setAccessible(true);

		final Map<Application, Parameters> params = (Map<Application, Parameters>) f.get(null); 
		params.clear();
	} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
	}
}

Running with JUnit 4, Java 8

qtran avatar Sep 18 '19 10:09 qtran

Would you be open to submitting a pull request?

brcolow avatar Sep 20 '19 18:09 brcolow