CMD ["java", "-XX:InitialRAMPercentage=70", "-XX:MaxRAMPercentage=70", "-jar", "api.jar"]
But docker stats
show MEM USAGE much lower 113MiB / 3.848GiB
.
It looks like this flags are ignored while -XX:+PrintFlagsFinal
show them. It is Java 14
. I tried this also with Java 11
.
What is happening here?
-Xmx1024m -Xms1024m
don’t change this too.
I have the newest docker on OS X.
Can you try adding a runner script, rather than passing flags in the Dockerfile? - I found that sometimes it munges the args and the final command is not quite what you need YMMV of course
I tried also bash
into image and run the app manually. Effect is the same.
And > -XX:+PrintFlagsFinal show them. So I see flags passed correctly.
size_t InitialHeapSize = 2894069760 {product} {ergonomic}
Everything looks fine, but in practice this memory is not consumed. At least from point of view docker stats
and top
wow it doesn’t also work even directly in my system
ps auwx|egrep "MEM|70964"|grep -v grep
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
kwladyka 70964 0.0 `0.5` 24216860 133284 s005 S+ 4:56PM 0:05.99 /usr/bin/java -XX:+PrintFlagsFinal -XX:InitialRAMPercentage=70 -XX:MaxRAMPercentage=70 -XX:MinRAMPercentage=70 -jar api.jar
It doesn’t make sense. Does it?How does it work then?
I found Xmx / Xms also don’t work
No idea, https://pl.wikipedia.org/wiki/Standardowa_odpowiedź_administratora ;-) - my only guess here would be that there's still something up with the flags, or the assumption is wrong: despite setting the min/max - the memory usage will be variable, but guaranteed to not go over the Max. Keep in mind: this is only about the heap size, JVM uses memory beyond just the heap
> JVM uses memory beyond just the heap yes, but I have too low usage, not to high what is even more strange
I'm failing to see how is that a concern - best strategy for production deployments is to always over-provision, monitor usage and adjust as necessary.
yes but I have the issue about memory usage only on specific environment and so far nobody solved this