-Xms : JVM初始内存大小。
-Xmx : JVM最大内存大小。
一般会把 -Xms 与 -Xmx 设置为同样大小,以避免每次GC后JVM重新分配内存。比如: -Xms 2048m -Xmx 2048m
-Xmn : 设置年轻代内存大小。 整个HEAP大小 = 年轻代 + 老年代 + 持久代.
虚拟机参数PermSize 与 MaxPermSize
网上找到的有关PermSize的解释
Permanent Generation (which is “Perm” in PermSize)
The permanent generation is used to hold reflective of the VM itself such as class objects and method objects. These reflective objects are allocated directly into the permanent generation, and it is sized independently from the other generations. Generally, sizing of this generation can be ignored because the default size is adequate. However, programs that load many classes may need a larger permanent generation.
PermSize is additional separate heap space to the -Xmx value set by the user. The section of the heap reserved for the permanent generation holds all of the reflective data for the JVM. You should adjust the size accordingly if your application dynamically load and unload a lot of classes in order to optimize the performance. Basically, he heap stores the objects and the perm gen keeps information about the objects inside of it. Therefore, the larger the heap, the larger the perm gen needs to be.
By default, MaxPermSize will be 32mb for -client and 64mb for -server. However, if you do not set both PermSize and MaxPermSize, the overall heap will not increase unless it is needed. When you set both PermSize and MaxPermSize, for example, 192mb, the extra heap space will get allocated when it startup and will stay allocated.
PermSize 是存放持久代(Permanent Generation)的。
持久代用于存放VM本身的反射,比如类对象还有方法对象。 这些反射对象直接存入持久代与其他的代际独立。一般来说默认的持久代大小就已经够了。但是,对需要加载很多类的的程序来说需要一个较大的持久代空间。
持久代(PermSize)是用户设置的-Xmx之外的堆空间。默认情况下MaxPermSize为32MB(client),64MB(Server)。但是,如果你不同时设置PermSize和MaxPermSize,总的对空间并不会立即分配,除非需要用到。 当你同时设置PermSize与MaxPermSize的话,比如256MB,这部份的堆空间就会在VM启动的时候立即分配。
-XX:MaxPermSize=256m -XX:PermSize=256m