StackOverFlowError
1 2 3 4 5 6 7 8 9 10
| public class StackOverFlowErrorDemo {
public static void main(String[] args) { dfs(); }
public static void dfs(){ dfs(); } }
|
最常见在递归中无返回条件一直调用。
JavaHeapSpace
1 2 3 4 5 6 7 8 9 10 11
| public class JavaHeapSpaceDemo {
public static void main(String[] args) { String str="wqoierihfsdkfsdf";
while (true){ str+=new Random().nextInt(108432432)+new Random().nextInt(238923293); str.intern(); } } }
|
GC Overhead Limited Exceeded
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
public class GCOverheadDemo {
public static void main(String[] args) { int i=0;
List<String> list=new ArrayList<>();
try { while (true){ list.add(String.valueOf(i++).intern()); } }catch (Throwable e){
System.out.println("********************"); System.out.println(i); e.printStackTrace();
} } }
|
DirectBufferMemory
1 2 3 4 5 6 7 8 9 10 11 12 13
|
public class DirectBufferMemoryDemo { public static void main(String[] args) {
System.out.println("配置的本地内存maxDirectMemory:"+sun.misc.VM.maxDirectMemory()/(double)1024/1024+"MB"); Buffer bb= ByteBuffer.allocateDirect(10*1024*1024); } }
|
Unable to create new native thread
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
public class UnableCreateNewThreadDemo { public static void main(String[] args) {
for (int i = 0; ; i++) { System.out.println("****************"+i); new Thread(()->{ try { Thread.sleep(Integer.MAX_VALUE); } catch (InterruptedException e) { e.printStackTrace(); } },String.valueOf(i)).start(); }
} }
|
调整最大线程数
ulimit -u 查看可以创建的最大线程
vim /etc/security/limits.d/90-nproc.conf