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= ...
Java is also a very high-level Object-Oriented programming language (OOP) which means that while the application code itself is much easier to maintain, the objects that are instantiated will use that much more memory.
But in 99% of the cases it is completely normal behaviour by the JVM. What you have specified via the -Xmx switches is limiting the memory consumed by your application heap. But besides the memory consumed by your application, the JVM itself also needs some elbow room.
No storage. Streams don't have storage for values; they carry values from a source (which could be a data structure, a generating function, an I/O channel, etc) through a pipeline of computational steps.
This resource memory used by the JVM is often called overhead. The recommended minimum starting memory point for 64-bit Maximo 7.5 JVMs systems is 3584 MB. Therefore we recommended that physical memory availability for each JVM be 4096 MB;0.5 GB is for JVM allocation and 512 MB is for overhead.
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 ;-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With