jetbrains系列IDE VMoptions 优化指南
jetbrains 系列IDE 是用java写的 佷吃内存 特别是你的项目目录很多很深的时候 例如 npm install --save
很多包的时候 还会卡死
优化 其实就是利用Java
的各种运行命令 来对程序进行优化
现在 让我们来看看 Java有哪些可以被我们使用的命令
bash 下输入
Ps:环境osx10.11.4 + java v1.8.0_92-b14
java
显示
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server,
because you are running on a server-class machine.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
Warning: this feature is deprecated and will be removed
in a future release.
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
Warning: this feature is deprecated and will be removed
in a future release.
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
查看一些高级的命令
java -X
显示
-Xmixed mixed mode execution (default)
-Xint interpreted mode execution only
-Xbootclasspath:<directories and zip/jar files separated by :>
set search path for bootstrap classes and resources
-Xbootclasspath/a:<directories and zip/jar files separated by :>
append to end of bootstrap class path
-Xbootclasspath/p:<directories and zip/jar files separated by :>
prepend in front of bootstrap class path
-Xdiag show additional diagnostic messages
-Xnoclassgc disable class garbage collection
-Xincgc enable incremental garbage collection
-Xloggc:<file> log GC status to a file with time stamps
-Xbatch disable background compilation
-Xms<size> set initial Java heap size
-Xmx<size> set maximum Java heap size
-Xss<size> set java thread stack size
-Xprof output cpu profiling data
-Xfuture enable strictest checks, anticipating future default
-Xrs reduce use of OS signals by Java/VM (see documentation)
-Xcheck:jni perform additional checks for JNI functions
-Xshare:off do not attempt to use shared class data
-Xshare:auto use shared class data if possible (default)
-Xshare:on require using shared class data, otherwise fail.
-XshowSettings show all settings and continue
-XshowSettings:all
show all settings and continue
-XshowSettings:vm show all vm related settings and continue
-XshowSettings:properties
show all property settings and continue
-XshowSettings:locale
show all locale related settings and continue
The -X options are non-standard and subject to change without notice.
The following options are Mac OS X specific:
-XstartOnFirstThread
run the main() method on the first (AppKit) thread
-Xdock:name=<application name>"
override default application name displayed in dock
-Xdock:icon=<path to icon file>
override default icon displayed in dock
从中抽取一些有用的命令
-d64 #选择以64位Java运行 //@todo 检查你系统的Java是64还是32的 再使用此项
-server #选择以服务器的模式运行Java程序
-Xincgc #启用增量垃圾收集
-Xms <大小> #设置初始Java堆大小
-Xmx <大小> #设置最大Java堆大小
-Xss <大小> #设置Java线程堆栈大小
编辑你使用的ide的配置文件
本人的系统osx 10.11.4
IDE为webstrom
ps:如果你想编辑全局的配置文件
bash
进入ide的安装文件夹的bin
目录
cd /Applications/WebStorm.app/Contents/bin
目录如下
fsnotifier java_pid12702.hprof libbreakgen64.dylib log.xml
idea.properties libMacNativeKit64.dylib libbreakgen64.jnilib printenv.py
inspect.sh libbreakgen.dylib libyjpagent.dylib restarter
java_pid11040.hprof libbreakgen.jnilib libyjpagent.jnilib webstorm.vmoptions
使用编辑器编辑webstorm.vmoptions
即可
编辑IDE本地配置
bash下输入下面命令 进入本地配置文件夹
cd ~/Library/Preferences/WebStorm2016.1
你会看到这样的目录
colors idea.properties options tasks
disabled_plugins.txt inspection port templates
disabled_update.txt javascript port.lock webstorm.vmoptions
fileTemplates jvm.md settings.jar webstorm120.key
编辑配置文件webstorm.vmoptions
楼主使用是sublime text 3
subl ./webstorm.vmoptions
原版的配置文件是这样的
#orgin
-Xms128m
-Xmx750m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=240m
-XX:+UseCompressedOops
修改成这样
#modify
-d64 # #此项根据你实际Java版本设置 //@TODO 建议升级java x64
-server
-Xms1024m #此项根据你实际内存大小设置 本人8g
-Xmx4096m #此项根据你实际内存大小设置 本人8g
-XX:MaxPermSize=1024m #此项根据你实际内存大小设置 本人8g
-XX:ReservedCodeCacheSize=240m #此项根据你实际内存大小设置 本人8g
-XX:+UseCompressedOops
-Xss4m
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+UseCodeCacheFlushing
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:MinHeapFreeRatio=15
-Xincgc
开始你的code吧!!
时间: 2024-10-07 18:10:33