GMapsFX
GMapsFX copied to clipboard
memory issue for many markers
Hello,
i need a kind of a car navigation in my java application. The GMapsFX has every feature i need and its very simple! Great Job!
But, i have a big memory Problem
I create every seconds a new Geo-Position (Lat and Long) and send it to my MapPresenter. An handlePositionEvent - Methods accept the new position and creteas a new Marker. I cache the previous marker
private Map<String, Marker> carMarkerMap = new HashMap<String, Marker>();
private GoogleMap map;
@Subscribe
public void handlePositionEvent(PositionEvent event) {
if (mapIsReady) {
Platform.runLater(new Runnable() {
@Override
public void run() {
// creates a NEW marker
Marker marker = createCarMarker(event.getCarName(),
event.getLatitude(), event.getLongitude());
String carName = event.getCarName();
if (carMarkerMap.containsKey(carName)) {
System.out.println("remove marker");
Marker m = carMarkerMap.get(carName);
map.removeMarker(m);
carMarkerMap.remove(carName);
m = null;
}
map.addMarker(marker);
carMarkerMap.put(carName, marker);
}
});
}
}
But i think, the Marker-Objects would not be destroy. After about 300 Markers, the application need 1 GB.
Does i make an misstake, or is it a bug?
thx
I've noticed something comparable. The weird thing is that the java VM does report it's memory is increasing drastically (for instance when looking at visual VM).
Currently my prime suspect are bugs in webkit, such as: https://javafx-jira.kenai.com/browse/RT-33729 (there are several comparable reports in the javafx bug database).
This is currently scheduled to be fixed in java 9 (the solution is to upgrade java to a newer webkit version).