1.基本简介:
最基本的两个参数是1. -Xms 初始堆大小(默认为物理内存的1/64) 2.-Xmx 最大堆大小(默认为物理内存的1/4),我们常常需要设置这两个参数。
1、Eclipse设置JVM参数
在eclipse.ini中:
-startup plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20120913-144807 -showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m --launcher.defaultAction openFile -vmargs -clean -Xms40m -Xmx512m
2.Tomcat的设置
Windows版本的:
bin/tomcat6w.exe文件打开之后:
设置大小即可。
Ubuntu下,在系统的/etc/init.d/tomcat6目录下修改,如:
# Default Java options # Set java.awt.headless=true if JAVA_OPTS is not set so the # Xalan XSL transformer can work without X11 display on JDK 1.4+ # It also looks like the default heap size of 64M is not enough for most cases # so the maximum heap size is set to 128M if [ -z "$JAVA_OPTS" ]; then JAVA_OPTS="-Djava.awt.headless=true -Xms512M -Xmx2048M" fi
java.lang.OutOfMemoryError: Java heap space
3.Jar包的运行
如:java -jar opencv249pro.jar -Xms512M -Xmx3560M
如果电脑内存不足,则会报错,应适当减小
参考博客:
【1】JVM参数配置与分析 :http://www.cnblogs.com/redcreen/archive/2011/05/04/2037057.html
【2】详解GC工作原理:http://developer.51cto.com/art/201103/248642.htm
【3】http://blog.csdn.net/jq_diy/article/details/4154132/
【4】Java中的堆栈及内存分配http://www.2cto.com/kf/201203/124798.html
【5】http://www.cubrid.org/blog/dev-platform/understanding-java-garbage-collection/