Common exceptions analysis (reproduced finishing) performance test

Heap memory overflow

java.lang.OutOfMemoryError: Java heap space
reasons: java heap memory is not enough or program has an infinite loop;
Resolution: If the java heap memory is not enough, need to be addressed by adjusting the JVM the following configuration:
  <the JVM-Arg> -Xms3062m </ Arg-JVM>
  <JVM-Arg> -Xmx3062m </ JVM-Arg>
 


java.lang.OutOfMemoryError: GC overhead limit exceeded
Cause: Insufficient memory, when thrown GC in order to release a very small space and take up a lot of time abnormalities
resolved:
  1, to see whether the system has an infinite loop code or use large memory;
  2, by adding JVM configured to limit memory usage: <JVM-Arg> -XX: -UseGCOverheadLimit </ JVM-Arg> a java.lang.OutOfMemoryError: the PermGen Space reason: P insufficient memory region
  
  

Resolution: by adjusting the JVM configuration:
  <JVM-Arg> -XX: MaxPermSize = 128M </ JVM-Arg>
  <JVM-Arg> -XXermSize = 128M </ JVM-Arg>

  The JVM Perm region is mainly used to store Class and Meta information, will be placed in Class years old when Loader, GC will not clean up the old year during the main program is running, the default size is 64M, when the program needs to be loaded objects relatively long time, more than 64M will be reported this memory overflow, the need to increase the memory allocation, generally 128m sufficient
  
java.lang.OutOfMemoryError: Direct buffer memory

The reason : stack overflow, or excessive levels of thread stack method call is too small.
Solve : Optimizer design, reduce call-layered approach; -Xss adjust parameters to increase the thread stack size.

Adjusting -XX: MaxDirectMemorySize = Parameter 

< jvm-arg>-XX:MaxDirectMemorySize=128m< /jvm-arg> 

java.lang.OutOfMemoryError:PermGen space


Java exception


Throwable
Throwable Java language is all wrong or abnormal superclass.
It comprises two subclasses of Throwable: Error and Exception. They indicate the occurrence of an abnormal situation
Throwable contains its thread create thread execution stack of snapshots, which provides printStackTrace () interfaces for data and other information to obtain a stack trace


Exception
Exception and its subclasses are a form of Throwable that indicates conditions that a reasonable application might want to catch


RuntimeException
RuntimeException is the superclass of those exceptions that might be thrown during the normal operation of the Java Virtual Machine.

Error
and Exception, as a subclass of Throwable Error is. It is used to indicate that a reasonable application should not try to catch serious problems, most of these errors are abnormal conditions.

Java will be thrown (Throwable) The structure is divided into three types:

  • Abnormalities to be examined (Checked Exception),
  • Abnormal (RuntimeException) runtime
  • Error (Error)


(01) 运行时异常
定义 : RuntimeException及其子类都被称为运行时异常
特点 : Java编译器不会检查它。 也就是说,当程序中可能出现这类异常时,倘若既”没有通过throws声明抛出它”,也”没有用try-catch语句捕获它”,还是会编译通过。例如,除数为零时产生的ArithmeticException异常,数组越界时产生的IndexOutOfBoundsException异常,fail-fail机制产生的ConcurrentModificationException异常等,都属于运行时异常。

(02) 被检查的异常
定义 : Exception类本身,以及Exception的子类中除了”运行时异常”之外的其它子类都属于被检查异常。
特点 : Java编译器会检查它。 此类异常,要么通过throws进行声明抛出,要么通过try-catch进行捕获处理,否则不能通过编译。例如,CloneNotSupportedException就属于被检查异常。当通过clone()接口去克隆一个对象,而该对象对应的类没有实现Cloneable接口,就会抛出CloneNotSupportedException异常。
被检查异常通常都是可以恢复的


(03) 错误
定义 : Error类及其子类
特点 : 和运行时异常一样,编译器也不会对错误进行检查。
当资源不足、约束失败、或是其它程序无法继续运行的条件发生时,就产生错误。程序本身无法修复这些错误的。例如,VirtualMachineError就属于错误。


Guess you like

Origin www.cnblogs.com/Zfc-Cjk/p/11231355.html