Quarkus: Native image of quickstart application has memory leak problem both native executable and docker version.

Created on 1 Sep 2019  路  2Comments  路  Source: quarkusio/quarkus

I built native image of quarkus quickstart application to native image both executable application and docker image then tested it with postman to test "http://localhost:8080/hello". I found that memory usage keep increase from 2 MB, 10 MB to 200 MB and keep going. I try to leave it but memory did not come down.

Expected behavior
Application should return memory at certain point.

Actual behavior

I used postman to test "/hello" 1,000 request with 5 ms delay. every round of testing memory increase around 20 MB.

To Reproduce
follow the guide https://quarkus.io/guides/getting-started-guide

and built image with

./mvnw package -Pnative -Dnative-image.docker-build=true

and run the application by

./target/getting-started-1.0-SNAPSHOT-runner

Then used postman to test "/hello" 1,000 request with 5 ms delay.

Screenshots

I tested both executable application and docker version.

This is memory usage on startup, around 2 MB
Screenshot from 2019-09-01 18-45-04

once I fire requests to it around 8,000 requests with 5 ms delay. Memory increase to 160 MB.
Screenshot from 2019-09-01 18-28-38

for docker. I also encountered same problem.
I ran docker with this command.
docker run -i --rm -p 8080:8080 quarkus-quickstart/getting-started

and use docker stats to inspect memory usage. I found same problem.
once, ran postman to fire request.
Screenshot from 2019-09-01 18-56-43

**Environment (please complete the following information):**
 - Output of `uname -a` : Linux 5.0.0-25-generic #26-Ubuntu SMP Thu Aug 1 12:04:58 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux (Ubuntu 19.02). 

 - Output of `java -version`: openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-20190711120915.buildslave.jdk8u-src-tar--b08)
OpenJDK 64-Bit GraalVM CE 19.2.0 (build 25.222-b08-jvmci-19.2-b02, mixed mode)
 - GraalVM version (if different from Java):  19.2.0
 - Quarkus version or git rev: 0.21.1

Maybe I am wrong, please advise if any.

kinbug triaginvalid

Most helpful comment

Hi,
Wow, I try to put ./getting-started-1.0-SNAPSHOT-runner -Xmx64m. it works now. Memory stay at around 9 MB.

I did not know before that native image is still java and also could apply jvm options to it. I thought that it's purely static executable application.

Maybe finding some place to document it.

Thank you so much, for your kindly suggestions.

All 2 comments

Hi,
I you run java without any max heap limit, it will takes (depending on the JVM used) around 1/4th of your memory for max heap (so hear 8GB). So it's normal that it is not cleaning the heap when it is around 160 MB.

I would suggest to set a upper bound for your java process (-Xmx128m for example) or/and for your docker container (Java will pick up it's default from the container memory limits).

Then, if you still encounters the same memory increase we can start looking at some issue :)

Hi,
Wow, I try to put ./getting-started-1.0-SNAPSHOT-runner -Xmx64m. it works now. Memory stay at around 9 MB.

I did not know before that native image is still java and also could apply jvm options to it. I thought that it's purely static executable application.

Maybe finding some place to document it.

Thank you so much, for your kindly suggestions.

Was this page helpful?
0 / 5 - 0 ratings