I am running Eclipse 4.3
with a Java 7 JRE
. When I upgrade to a Java 8 JRE
, Eclipse suddenly consumes more memory. If I launch Eclipse with JRE 7
directly into my workspace, it allocates 600 MB of RAM according to Task Manager. When I use JRE 8
, this value is 750 MB.
Even worse, If I run a large Java program which typically allocates about 10 GB of RAM with JRE 7
, switching to JRE 8
causes it to allocate 12 GB of RAM.
Does anybody know what causes this extra RAM allocation? I have tested tweaking different options but with zero success:
-XX:ReservedCodeCacheSize=
-XX:MaxMetaspaceSize=
-XX:MetaspaceSize=
...
In the way question is asked
why Java 8 allocating too much memory on my machine
I don't think anyone will be able to answer, however there are several guidelines which might help. Given that you are measuring memory via task manager you are interested in total RSS used. So
java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version
command for both jdks. Using text sort on top of output you'll be able to get a nice diff using any compare tool. Things like changing default GC collector and thread stack size will affect final RSS a lot. heap + metasize + code cache + native + (thread_stack_size * maximum_number_of_threads)
jmap
tool. No need to play with flag, you can get number and just compare whenever it's increased or not. jcmd
and it has extensive documentation in oracle docs. Non technical - whilst tweaking various options in order to reduce memory can help, the chances of getting right values are close to finding needle in haystack. I would really recommend to have a about how RSS is used in java. This knowledge will be handy for quite a few years!
Please let me know whenever you'd like more concrete references or better explanation. And... good luck with your quest ;-)
I can confirm that a Web application I am working on (Jetty, Struts2, JDBC) consumes about 300 MBs more RAM (1.2G) right after startup when running in JRE 1.8.0_72 compared to JRE 1.7.0_80. The application is running on Centos 6 x64 and to make the memory measurement as transparent as possible I have disabled swap and set -Xms equal to -Xmx (40% of available RAM). I have used dstat --top-mem
or top -m
to get the total memory consumed by the java process.
Moreover when Web clients are connecting too often to the application, the total consumed memory rises until the system gets out of memory and kills the java process. The only what I can see is an information in /var/log/messages:
Nov 10 21:29:54 my kernel: Out of memory: Kill process 26610 (java) score 570 or sacrifice child
When I run an infinite loop from bash that invokes 4 parallel Web clients that connect to the application (= establish new TCP connection), request the application status and disconnect then the total memory consumed by the application rises about 100-200 KBs each minute. Each client does 6-10 requests per minute. Used heap memory size is stable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.