Dear friends, I’m developing an android app and I need to find the closest edge from latitude and longitude.
Snap qr = hopper.getLocationIndex().findClosest(latitude, longitude, EdgeFilter.ALL_EDGES);
With small osm.pbf files (1/2 MB) everything was ok, now instead i load the following osm.pbf file
Sud Italy (more or less 250 MB) I’m getting this error:
E/AndroidRuntime: FATAL EXCEPTION: Timer-4
Process: com.*.*, PID: 24530
java.lang.OutOfMemoryError: Failed to allocate a 1284541136 byte allocation with 25149440 free bytes and 238MB until OOM, max allowed footprint 311732600, growth limit 536870912
at com.graphhopper.storage.BaseGraph.fetchWayGeometry_(BaseGraph.java:400)
at com.graphhopper.storage.BaseGraph.access$100(BaseGraph.java:43)
at com.graphhopper.storage.BaseGraph$EdgeIteratorStateImpl.fetchWayGeometry(BaseGraph.java:864)
at com.graphhopper.storage.index.LocationIndexTree.traverseEdge(LocationIndexTree.java:331)
at com.graphhopper.storage.index.LocationIndexTree.lambda$findClosest$1$LocationIndexTree(LocationIndexTree.java:283)
at com.graphhopper.storage.index.-$$Lambda$LocationIndexTree$IxB7P67mFqGhKi5xV92xZXcW4ZE.accept(Unknown Source:13)
at com.graphhopper.storage.index.LineIntIndex.fillIDs(LineIntIndex.java:151)
at com.graphhopper.storage.index.LineIntIndex.findEdgeIdsInNeighborhood(LineIntIndex.java:242)
at com.graphhopper.storage.index.LocationIndexTree.findClosest(LocationIndexTree.java:280)
at com.*.*.adapters.GraphhopperRouteAdapter.findClosestEdgeFromPoint(GraphhopperRouteAdapter.java:285)
But why should there be a problem with CH only? Did you test CH using a similar size and did it still crash?
We did test it at that time and the limit was purely related to some strange Android limit. In the end I found the per-process limit even in the Android source code.
Ok, so you did not do tests regarding the graph size. I would just like to avoid the misinterpretation and CH might be just bigger in size resulting in these memory problems.
that is five time more bigger than the actually. The problem is that now i need to call findClosest method on my new module , the fetchWayGeometry_ method is called with mode PILLAR_AND_ADJ and
long geoRef = Helper.toUnsignedLong(this.store.getGeoRef(edgePointer));
int count = 0;
byte[] bytes = null;
if (geoRef > 0L) {
geoRef *= 4L;
count = this.wayGeometry.getInt(geoRef);
geoRef += 4L;
bytes = new byte[count * this.nodeAccess.getDimension() * 4];
this.wayGeometry.getBytes(geoRef, bytes, bytes.length);