mockserver icon indicating copy to clipboard operation
mockserver copied to clipboard

java.lang.OutOfMemoryError: Java heap space

Open stanosamek opened this issue 2 years ago • 3 comments
trafficstars

Hi,

we have a problem with OutOfMemoryError: Java heap space after loading expectations and running some tests. We are using mockserver in version 5.13.2 and we are running server with helm chart on Kubernetes. We were trying to fix issue with switching storing expectations into file system with parameter mockserver.persistExpectations=true but mockserver is still using approx. 600MB and failing on heap space.

We were also trying to add jvmOptions into values.yaml. In deployment we can see environment property JVM_OPTIONS.

spec:
  containers:
    - env:
      - name: MOCKSERVER_LOG_LEVEL
         value: INFO
      - name: SERVER_PORT
         value: '1080'
      - name: JVM_OPTIONS
         value: '-Xms1G -Xmx2G'
    image: nexus/ps-sq002-pub/mockserver/mockserver:5.13.2

How can we increase JVM heap for mockserver?

Thank you

stanosamek avatar May 17 '23 14:05 stanosamek

I'm also seeing some memory pressure issues when running on k8s via the helm chart, the memory usage looks very leaky. image

tstonely-mt avatar May 24 '23 10:05 tstonely-mt

@stanosamek @tstonely-mt did you ended up finding a solution? We're seeing the same problem here...

thomasjoulin avatar Feb 01 '24 08:02 thomasjoulin

@thomasjoulin Yes, in the end we ended up setting the memory config properties. I think it was the two below. Memory usage stabilised after that :+1:

# maximum number of expectations held in the in-memory ring buffer
mockserver.maxExpectations=1000

# maximum number of log entries to hold in memory, this include recorded requests, expectation match failures and other log entries
mockserver.maxLogEntries=5000

tstonely-mt avatar Feb 01 '24 09:02 tstonely-mt