No matter the size of the graph and the server I use, any time I attempt to route by the dijkstra_one_to_many algorithm, I overflow my heap. Test environment is a m3.2xlarge with 30gb of RAM and 2x80gb SSD drives.
java.lang.OutOfMemoryError: Java heap space
I've tracked down the code block that is the problem inside com.graphhopper.routing.DijkstraOneToMany
in the findEndNode method:
while (true) {
visitedNodes++;
EdgeIterator iter = outEdgeExplorer.setBaseNode(currNode);
while (iter.next()) {
int adjNode = iter.getAdjNode();
int prevEdgeId = edgeIds[adjNode];
if (!accept(iter, prevEdgeId))
continue;
double tmpWeight = weighting.calcWeight(iter, false, prevEdgeId) + weights[currNode];
if (Double.isInfinite(tmpWeight))
continue;
double w = weights[adjNode];
if (w == Double.MAX_VALUE) {
parents[adjNode] = currNode;
weights[adjNode] = tmpWeight;
heap.insert_(tmpWeight, adjNode);
changedNodes.add(adjNode);
edgeIds[adjNode] = iter.getEdge();
} else if (w > tmpWeight) {
parents[adjNode] = currNode;
weights[adjNode] = tmpWeight;
heap.update_(tmpWeight, adjNode);
changedNodes.add(adjNode);
edgeIds[adjNode] = iter.getEdge();
}
}
if (heap.isEmpty() || isMaxVisitedNodesExceeded() || isWeightLimitExceeded())
return NOT_FOUND;
// calling just peek and not poll is important if the next query is cached
currNode = heap.peek_element();
if (finished())
return currNode;
heap.poll_element();
}
```
It seems to never find the end node and the internal data structure (min heap?) grows and grows and grows until I run out of heap space. Why is this happening?
I can post my config.properties as well if that is needed. Thank you Peter for putting together an awesome piece of open source software.