Search code examples
javaspring-bootout-of-memoryspring-cloudjvm-hotspot

Memory issue during JAR execution


I have about 8 API's JAR and 4 from spring cloud (Zuul,Hystrix,Config-Server,Eureka). I am running all the jars in one server right now though we will scale up later when going to production.

The AWS Linux server has a 16GB memory. The problem I am having is the server constantly runs out of memory for some reason and when i try to execute a Jar I get below error.

Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x000000078fb80000, 293601280, 0) failed; error='Cannot allocate memory' (errno=12)

The error is not specific to specific jar it is random.

Memory from server (Currently I have 9 jars deployed ):-

free -m

             total        used        free      shared  buff/cache   available
Mem:          15630       13684        1835          17         110        1781

Has anyone faced a similar issue. Can provide more info if any other information is required.

Any help will be appreciated.


Solution

  • I added the java arguments to the execution jobs which seems to solve the problem .

    java -Xmx64m -Xss256k -jar abc.jar

    After this even though I had 13 jars deployed on the same server I had 10GB worth of memory left and which was 1.7GB before I added the arguments.

    Memory Before JAVA arguments:

    free -m
    
                  total        used        free      shared  buff/cache   available
    
    Mem:          15630       13684        1835          17         110        1781
    

    Memory After Java Arguments:


    free -m
    
                  total        used        free      shared  buff/cache   available
    
    Mem:          15630        4927        8769          25        1932       10373