In Spring Boot application, you can set the JVM parameters by two ways so that increase the JVM heap size, in case required you can also configure the other parameters like GC alogorithms, MetaSpace etc.
- Configure Parameters in pom.xml: To pass the JVM parameters for an application , we can set these parameters in spring-boot-maven-plugin in pom.xml plugin section.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>-Xms512m -Xmx1024m -XX:+UseZGC -XX:MaxMetaspaceSize=512m</jvmArguments>
</configuration>
</plugin>
- Pass JVM parameters through Command line: We can pass the JVM parameters through the command line while running the Spring Boot application jar file.
java -jar zyz-service.jar -Dspring-boot.run.jvmArguments="-Xms512m -Xmx1024m -XX:+UseZGC -XX:MaxMetaspaceSize=512m"
Note: In both the cases these parameters are as below :
- -Xms512m : Minimum heap size allocate for JVM as 512 MB.
- -Xmx1024m : Max heap size can be allocate for JVM as 1024 MB.
- -XX:+UseZGC : Garbage collection algorithm as Z Garbage Collector.
- -XX:MaxMetaspaceSize=512m : By default in Java 8 or after the MetaSpace size is unlimited but we can configure fix Max limit also.
Let me know the your thought on this post. If this was helpful for make a comment.
Happy Learning !!!
You must log in to post a comment.