OOME from GraphLayout.parseInstance().toFootprint()

Dmitry Vyazelenko vyazelenko at yahoo.com
Thu Sep 21 17:29:51 UTC 2017


Hi,

I have the following code that throws OutOfMemoryError on 8 GB heap:

LinkedList<Integer> linkedList = new LinkedList<>();
for (int i = 0; i < 1_000_000; i++) {
  linkedList.add(i);
}
System.out.println(GraphLayout.parseInstance(linkedList).toFootprint());

The problem is with the GraphWalker which accumulates GraphPathRecord objects whose path field is ever growing but in the case of toFootprint() call this field is not used at all.

Suggestion: compute path lazily in path() method using a reference to parent GraphPathRecord object. 

Best regards, 
Dmitry Vyazelenko


More information about the jol-dev mailing list