heavywar
heavywar

Reputation: 149

i can't set -Xmx in java

I use spring-boot 2. If i do :

export _JAVA_OPTIONS=-Xmx756m

Then:

java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'

 intx CompilerThreadStackSize                   = 0                                   {pd product}
uintx ErgoHeapSizeLimit                         = 0                                   {product}
uintx HeapSizePerGCThread                       = 87241520                            {product}
uintx InitialHeapSize                          := 16777216                            {product}
uintx LargePageHeapSizeThreshold                = 134217728                           {product}
uintx MaxHeapSize                              := 792723456                           {product}
 intx ThreadStackSize                           = 1024                                {pd product}
 intx VMThreadStackSize                         = 1024                                {pd product}

But if i reload console. MaxHeapSize is reset .

And it changes nothing :

java -XshowSettings:all
VM settings:
Max. Heap Size (Estimated): 237.81M
Ergonomics Machine Class: client
Using VM: OpenJDK 64-Bit Server VM

if i do :

 nohup java -Dspring.profiles.active=dev -Xmx660m -jar /home/ec2-user/project.jar >test.out 2>&1 &

in text.out:

nohup: ignoring input
VM settings:
    Max. Heap Size: 660.00M
    Ergonomics Machine Class: client
    Using VM: OpenJDK 64-Bit Server VM

But if I enter manually java -XshowSettings:all Nothing changes:

VM settings:
    Max. Heap Size (Estimated): 237.81M
    Ergonomics Machine Class: client
    Using VM: OpenJDK 64-Bit Server VM

and:

uintx MaxHeapSize                              := 257949696                           {product}

Total memory:1gb

Upvotes: 1

Views: 841

Answers (1)

Milan Desai
Milan Desai

Reputation: 1306

But if i reload console. MaxHeapSize is reset .

This is not how JVM works. In order to get your memory related changes to take place one has to restart java programme. It is not possible to apply jvm settings on the fly

Upvotes: 1

Related Questions