0
votes

I created a simple service that performs 4 HTTP calls and 4 db calls to collect some data and pass it to the HTTP response as JSON.

As I start the application (native, no docker), I see it consumes 7MB, sometimes 15MB sometimes 30MB. Good.

As I start loading testing it, sending 1 request every 10 milliseconds, in total 100 requests.

I noticed the memory consumption goes to 200MB right away. Then after 5-6 more tests to 400MB. (As much is Spring Boot version of it takes).

Question is: is it expected to be like that?

Should it be trying be minimalist (for the native v of it) about the memory and clean after itself, at least after n minutes or so? Is there are settings for that?

1

1 Answers

1
votes

I'm no expert on GraalVM native images, but from a quick local test with a "Hello world" app, I'm seeing similar numbers to you. It seems if you don't set a limit on max heap size, one will be chosen automatically (not sure about criteria). You can start your app with -XX:+PrintGC to see memory activity. Then, you can experiment with -Xmx (e.g. -Xmx32m to set max heap size to 32 MB) -- the more memory you give to the app, the less frequent garbage collection cycles will be. This article shows some more interesting GC options: https://e.printstacktrace.blog/graalvm-heap-size-of-native-image-how-to-set-it/