15

We have a Java application running in openjdk8 whose max heap memory changes at runtime - what might be the reason of that?

I have found question Why the heap is changing in java which points to the article which explains difference between max and committed memory. It seems that in our case these two are usually the same, but not always - see at 11:53 on screenshots below.

Heap can be also changed be young generation serial collector (-XX:MaxHeapFreeRatio, see Encourage the JVM to GC rather than grow the heap?), however we use parallel collector so this is not the case.

The memory related JVM parameters that we run the application with:

-XX:MaxMetaspaceSize=200M -Xms2000m -Xmx2000m

Not sure if it's related, the application was doing parallel mark sweep on old generations between 11:55 and 11:58 - at this time there was over 200MB free memory available and we cannot see any reason for that behaviour.

Heap Memory Mark Sweep Count

Jaroslaw Pawlak
  • 5,538
  • 7
  • 30
  • 57
  • 1
    The question lacks JVM options and relevant GC logs. – apangin Apr 24 '18 at 17:50
  • 1
    BTW, `-XX:+UseAdaptiveSizePolicy` is turned on by default. – apangin Apr 24 '18 at 18:00
  • @apangin I have added JVM options to the question. Our GC logging is disabled so I can't provide them for this case. We would have to enable them and wait for this to happen again. – Jaroslaw Pawlak Apr 25 '18 at 10:50
  • 1
    So you are using Parallel GC which has adaptive size policy on by default. Set `-XX:-UseAdaptiveSizePolicy` if you don't want heap generations to resize. – apangin Apr 25 '18 at 15:34
  • 1
    @apangin how come this is not an answer? Exactly what the OP asked – Eugene Apr 27 '18 at 09:21

1 Answers1

10

You are using Parallel GC which has adaptive size policy on by default.
Set -XX:-UseAdaptiveSizePolicy if you don't want heap generations to resize.

apangin
  • 92,924
  • 10
  • 193
  • 247