mock-server / mockserver

MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
http://mock-server.com
Apache License 2.0
4.58k stars 1.07k forks source link

java.lang.OutOfMemoryError: Java heap space #1741

Open stanosamek opened 1 year ago

stanosamek commented 1 year ago

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

tstonely-mt commented 1 year ago

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

thomasjoulin commented 7 months ago

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

tstonely-mt commented 7 months ago

@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