Spring Boot memory consumption increases after -Xmx option

I noticed that the Spring application for loading does not execute the amount of memory set with the Xmx option. For example: java -Xss64m -Xmx64m -jar test.jar

I also printed on the console the amount of memory actually used at startup 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 such an increase? It should give "java.lang.OutOfMemoryError: PermGen space", but not increase this path.

This makes me worried if many applications might not have memory on the server. By the way, I'm using Java 1.8_45

+5
source share
1 answer

After monitoring the Spring boot application, I figured out some possible reasons, such as:

  • Number of HTTP streams (Undertow starts about 50 streams per default, but you can increase / decrease the number of required streams through the property)
  • Access to firmware (.dll, .so) through JNI
  • Static Variables
  • Using cache (memcache, ehcache, etc.)
  • If the virtual machine is 32-bit or 64-bit, 64 bits use more memory to work with the same application, so if you do not need a heap larger than 1.5 GB, save the application 32 bits to save memory.
+6
source

All Articles