When deploying Java application to TPCF, the Java buildpack helps creating Java start command such as
$ cf app APP_NAME
...
start command: JAVA_OPTS="-agentpath:$PWD/.java-buildpack/open_jdk_jre/bin/jvmkill-1.17.0_RELEASE=printHeapHistogram=1 -Djava.io.tmpdir=$TMPDIR -XX:ActiveProcessorCount=$(nproc) -Djava.ext.dirs= -Djava.security.properties=$PWD/.java-buildpack/java_security/java.security $JAVA_OPTS" && CALCULATED_MEMORY=$($PWD/.java-buildpack/open_jdk_jre/bin/java-buildpack-memory-calculator-3.13.0_RELEASE -totMemory=$MEMORY_LIMIT -loadedClasses=13435 -poolType=metaspace -stackThreads=250 -vmOptions="$JAVA_OPTS") && echo JVM Memory Configuration: $CALCULATED_MEMORY && JAVA_OPTS="$JAVA_OPTS $CALCULATED_MEMORY" && MALLOC_ARENA_MAX=2 SERVER_PORT=$PORT eval exec $PWD/.java-buildpack/open_jdk_jre/bin/java $JAVA_OPTS -cp $PWD/.:$PWD/.java-buildpack/container_security_provider/container_security_provider-1.20.0_RELEASE.jar org.springframework.boot.loader.launch.JarLauncher
In above output, it is unclear what exact value of some JVM options, such as the CALCULATED_MEMORY.
TPCF all release
In order to know the exact Java start command, there are multiple options.
The simplest way is `cf ssh` into the container, execute `ps aux` to list all processes including the Java process.
However if `cf ssh` is disabled on the platform, as one alternative, you can make use of '-XX:+PrintFlagsFinal' to print out all JVM options in app logs, including the effective value of MetaspaceSize. For example, set JAVA_OPTS like
JAVA_OPTS: '-XX:+PrintFlagsFinal -XX:MaxMetaspaceSize=512M'
Another alternative is to implement in the application, then access it at https://<APP_ROUTE>/jvm
@RestController
public class Controller {
@GetMapping("/jvm")
public String hello() {
RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
String jvmArguments = runtimeMxBean.getInputArguments().toString();
System.out.println("JVM arguments : " + jvmArguments);
return jvmArguments;
}
}