I noticed Spring Boot application does not obey the amount of memory set via Xmx option. For example: java -Xss64m -Xmx64m -jar test.jar
I also printed on console the amount of memory really used by application at startup, and shows: Max memory: 61M
long maxBytes = Runtime.getRuntime().maxMemory();
System.out.println("Max memory: " + maxBytes / 1024 / 1024 + "M");
When I open Windows processes before accessing any web page, it shows +-105M, so how can Java say 61M?
After accessing any web page it goes from +-125M to +-135M. Why is there such increase? It should give "java.lang.OutOfMemoryError: PermGen space" but do not increase this way.
It makes me get worried, if many applications could run out of memory at the server. By the way, I am using Java 1.8_45
Disadvantages of Spring BootSpring Boot creates a lot of unused dependencies, resulting in a large deployment file; The complex and time-consuming process of converting a legacy or an existing Spring project to a Spring Boot application; Not suitable for large-scale projects.
The default value for the minimum heap is 8 Mb or 1/64th of the physical memory within the 8 Mb to 1 Gb range. The default value for the maximum heap is 1/4th of the physical memory for physical memory greater than 192 MB, otherwise, it's 1/2th of the physical memory.
You can get a simple Spring Boot app down to around 72M total by using the following JVM options. With -XX:MaxRAM=72m This will restrict the JVM's calculations for the heap and non heap managed memory to be within the limits of this value.
@Document is an annotation provided by Spring data project. It is used to identify a domain object, which is persisted to MongoDB. So you can use it to map a Java class into a collection inside MongoDB. If you don't use Spring Data, you don't need this annotation.
After monitoring the Spring Boot application, I found out some possible reasons such as:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With