public String getWorkerMemParameter ( LocalAssignment assignment , Map totalConf , String topologyId , Integer port ) { long memSize = assignment . getMem ( ) ; long memMinSize = ConfigExtension . getMemMinSizePerWorker ( totalConf ) ; long memGsize = memSize / JStormUtils . SIZE_1_G ; int gcThreadsNum = memGsize > 4 ? ( int ) ( memGsize * 1.5 ) : 4 ; String childOpts = getChildOpts ( totalConf ) ; childOpts += getGcDumpParam ( topologyId , port , totalConf ) ; StringBuilder commandSB = new StringBuilder ( ) ; memMinSize = memMinSize < memSize ? memMinSize : memSize ; commandSB . append ( " -Xms" ) . append ( memMinSize ) . append ( " -Xmx" ) . append ( memSize ) . append ( " " ) ; if ( memMinSize <= ( memSize / 2 ) ) { commandSB . append ( " -Xmn" ) . append ( memMinSize / 2 ) . append ( " " ) ; } else { commandSB . append ( " -Xmn" ) . append ( memSize / 2 ) . append ( " " ) ; } // PermSize is deprecated in jdk1.8 if ( JDKInfo . isJdk7 ( ) || JDKInfo . lessThanJdk7 ( ) ) { if ( memGsize >= 2 ) { commandSB . append ( " -XX:PermSize=" ) . append ( memSize / 32 ) ; } else { commandSB . append ( " -XX:PermSize=" ) . append ( memSize / 16 ) ; } commandSB . append ( " -XX:MaxPermSize=" ) . append ( memSize / 16 ) ; } else if ( JDKInfo . isJdk8 ( ) ) { if ( memGsize >= 2 ) { commandSB . append ( " -XX:MetaspaceSize=" ) . append ( memSize / 32 ) ; } else { commandSB . append ( " -XX:MetaspaceSize=" ) . append ( memSize / 16 ) ; } commandSB . append ( " -XX:MaxMetaspaceSize=" ) . append ( memSize / 16 ) ; } commandSB . append ( " -XX:ParallelGCThreads=" ) . append ( gcThreadsNum ) ; commandSB . append ( " " ) . append ( childOpts ) ; if ( ! StringUtils . isBlank ( assignment . getJvm ( ) ) ) { commandSB . append ( " " ) . append ( assignment . getJvm ( ) ) ; } return commandSB . toString ( ) ; }
Get worker s JVM memory setting