Java程序启动报如下错误

启动Tomcat报如下错误,是怎么回事:

Java HotSpot(TM) 64-Bit Server VM warning: G1 GC is disabled in this release.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

The stack size specified is too small, Specify at least 328k
已邀请:

空心菜 - 心向阳光,茁壮成长

赞同来自: chris

Java HotSpot(TM) 64-Bit Server VM warning: G1 GC is disabled in this release.
首先如上提示你的Java版本不支持G1收集器,所以需要把你的java命令启动参数里面-XX:+UseG1GC等相关参数去掉。   
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

The stack size specified is too small, Specify at least 328k
第二,如上可知,你设置的-Xss的每个线程的堆栈大小值太小了,提示最少为328k ;
JDK5.0以后每个线程堆栈大小为1M,以前每个线程堆栈大小为256K。更具应用的线程所需内存大小进行调整。在相同物理内存下,减小这个值能生成更多的线程。但是操作系统对一个进程内的线程数还是有限制的,不能无限生成。

Xss越大,每个线程的大小就越大,占用的内存越多,能容纳的线程就越少;Xss越小,则递归的深度越小,容易出现栈溢出 java.lang.StackOverflowError。减少局部变量的声明,可以节省栈帧大小,增加调用深度。  

要回复问题请先登录注册