We are developing a JavaFX application which shows large number of houses(16000).
When we try to put large number of markers(16000) on google map, the memory utilization for that java process get increased continuously and machine/application get crashed (After allocating more that 2.5Gb of memory to the java process).
This application works fine with java 7 (version 1.7.0_71) but when we upgrade the version of java to java 8 memory utilization for java process get increased.
In this application we iterate through a list of houses and and buffer lattitude and longitude of each house in JSONArray and when length of JSONArray becomes more than 5000 we make a javascript call for putting markers for those houses(5000 at once).
We buffer information of each house because if we make a javascript call for each houses while iterating a list from java then we almost make thousands of javascript call unnecessarily and even we use java 7 application get crashed.
Observations:
1. If we make thousands of javascript functions call from java without performing any operation on map (just print logs) all works fine.
2. Memory utilization increases only when we make operations on map.
3. Memory allocated to the java process never get decreased even if heap memory get decreased.
4. If we comment out JavaScript calls from java then memory utilization is fine and application is also working fine.
We also observed that whatever memory allocated to the Java Process/JavaScript/WebEngine/WebView/Webkit is not deallocated even if you perform GC from jvisualvm, so memory is always allocated and never claimed back to the operating system(Note: This happens with java 7 also).
Steps to reproduce this issue
1. Create a JavaFX application
2. Add webview in it
3. Load google map on webview (Use google maps javascript api v3)
4. Add JavaFX button
5. On click of button try with following two options
A. Pass long json array (more than 15000 records) at once containing lattitude and longitude to javascript OR
B. Break that array (size of 5000) and pass one by one to javascript.
Observations:
With the first option javascript will receive all records but some of it will get skipped while putting it on map. (Tested on java 7)
The second option works fine in java 7 but in java 8 gives memory leak
6. In javascript parse that array and try to put marker for each record
Observatios:
I have separated out the html page and try to put markers on it using chrome and it works fine. Just to check if there is any leak in google map.