3282788 at com.chedaia.task.address.util.ParkingPointUtil.getPreviewGpsPoint(ParkingPointUtil.java:410) 3282789 at com.chedaia.task.address.util.ParkingPointUtil.getPreviewGpsPoint(ParkingPointUtil.java:410) 3282790 Exception in thread "pool-250-thread-43" java.lang.StackOverflowError 3282791 at java.util.AbstractCollection.toArray(AbstractCollection.java:183) 3282792 at java.lang.String.split(String.java:2378) 3282793 at com.chedaia.task.address.util.ParkingPointUtil.isGps(ParkingPointUtil.java:32) 3282794 at com.chedaia.task.address.util.ParkingPointUtil.getPreviewGpsPoint(ParkingPointUtil.java:406) 3282795 at com.chedaia.task.address.util.ParkingPointUtil.getPreviewGpsPoint(ParkingPointUtil.java:410) 3282796 at com.chedaia.task.address.util.ParkingPointUtil.getPreviewGpsPoint(ParkingPointUtil.java:410) 3282797 at com.chedaia.task.address.util.ParkingPointUtil.getPreviewGpsPoint(ParkingPointUtil.java:410) 3282798 at com.chedaia.task.address.util.ParkingPointUtil.getPreviewGpsPoint(ParkingPointUtil.java:410) 3282799 at com.chedaia.task.address.util.ParkingPointUtil.getPreviewGpsPoint(ParkingPointUtil.java:410)
原因
递归调用次数太多导致 且启动脚本中设置了-Xss
1
-XX:PermSize=128m -Xss256k
解决办法
由于涉及到的代码依赖较多,先不改动代码 加大线程栈大小到2m
1
-XX:PermSize=128m -Xss2m
线程栈大小与递归次数测试
代码
1 2 3 4 5 6 7 8 9
public static void main(String[] args) { recursion(0); }
public static void recursion(int i) { System.out.println(i); i++; recursion(i); }
执行结果
结果:966
此时的栈设置为: -Xss128k
1 2 3 4 5 6 7 8 9 10
963 964 965 966 Exception in thread "main" java.lang.StackOverflowError at sun.nio.cs.UTF_8.updatePositions(UTF_8.java:77) at sun.nio.cs.UTF_8.access$200(UTF_8.java:57) at sun.nio.cs.UTF_8$Encoder.encodeArrayLoop(UTF_8.java:636) at sun.nio.cs.UTF_8$Encoder.encodeLoop(UTF_8.java:691) at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java
public static void recursion(int i) { System.out.println(i); long a = 1l; long b = 2l; long c = a + b; i++; recursion(i); }
在栈大小设置为: -Xss128k 时,结果是:623
1 2 3 4 5 6 7 8 9
620 621 622 623 java.lang.StackOverflowError at sun.nio.cs.UTF_8.updatePositions(UTF_8.java:77) at sun.nio.cs.UTF_8.access$200(UTF_8.java:57) at sun.nio.cs.UTF_8$Encoder.encodeArrayLoop(UTF_8.java:636) at sun.nio.cs.UTF_8$Encoder.encodeLoop(UTF_8.java:691)