FULL PRODUCT VERSION :
ADDITIONAL OS VERSION INFORMATION :
Tested on most Windows platforms from Vista upwards.
A DESCRIPTION OF THE PROBLEM :
We are trying to run a JavaScript based GUI inside a WebView but suffer from an apparent memory leak. Even the simplest code we can come up with appears to have this problem.
The test GUI side just alternates between two pages, as follows:
Page1:
<head></head>
<body>
<h1>Page 1</h1>
<script>window.location.href = "page2.html";</script>
</body>
Page 2:
<head></head>
<body>
<h1>Page 2</h1>
<script>window.location.href = "page1.html";</script>
</body>
The Java application is as follows:
import java.awt.Dimension;
import java.io.IOException;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
import javafx.scene.web.WebView;
import javax.swing.JFrame;
public class FXBrowser
{
private final JFrame frame;
public FXBrowser()
{
JFXPanel fxPanel = new JFXPanel();
frame.add(fxPanel);
Platform.runLater(() -> initFX(fxPanel));
frame.pack();
frame.setVisible(true);
}
private void initFX(JFXPanel fxPanel)
{
fxPanel.setScene(new Scene(createMainWebView()));
}
private WebView createMainWebView()
{
WebView webComponent = new WebView();
webComponent.getEngine().load("<url to above pages>");
return webComponent;
}
public static void main() throws IOException
{
FXBrowser gui = new FXBrowser();
System.in.read();
}
}
Running this for just 5 minutes is enough to increase memory usage by a few hundred MB. Garbage collection appears unable to free anything up.
Note that we have also tested this with many versions of JavaFX from 1.8.0_66 onwards.
There is also another user reporting a very similar problem here http://stackoverflow.com/questions/36266013/exploding-memory-usage-in-javafx-webview-while-loading-many-pages
Due to this behavior, we have decided to run our GUI inside a browser instead i.e. We are NOT waiting on a fix. I have raised this bug purely to document the fact that it was seen.
Please let me know if you need any further information. I will be happy to help.
Thanks,
Lee Perry
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use the code examples in the description. Note you will need to enter the actual URL to wherever you save the GUI pages.
REPRODUCIBILITY :
This bug can be reproduced always.