-XX:+UseParNewGC parameter for single CPU environment [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
We are using CMS gc for our java application. We wonder what would happen if we set gc parameter as -XX:+UseParNewGC instead of let it be the default in a single CPU environment. Will it change performance? If we use -server flag, parallel copying collector will be taken by jvm or we should always explicitly mention it?

From the Oracle GC tuning docs about the parallel gc:
On a machine with N hardware threads where N is greater than 8, the
parallel collector uses a fixed fraction of N as the number of garbage
collector threads. The fraction is approximately 5/8 for large values
of N. At values of N below 8, the number used is N.
found here
So you probable won't benefit unless your cpu is multithreaded. Also a good read is the section 5 of the aforementioned docs.

Related

Comparison tests of OpenJ9 and HostSpot G1 for elastic vertical scaling [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
In containerized environments we have huge waste in terms of resources when use java. In terms of vertical scaling we need to have an optimized JVM. Are there any public comparison tests available of vertical scaling and memory usage of OpenJ9 and HotSpot G1
Is OpenJDK 12 better than J9 for vertical scaling?
It's hard to answer at this stage as there are no publicly available comparison tests. Now both JVMs look good in terms of elasticity.
There is one known issue related to monitoring mechanism of the committed RAM.
With OpenJ9 you have to do it on OS level
To test vertical scaling with respect to memory in OpenJ9 I recommend to monitor the resident-set-size (RSS) of a Java process with a script like this:
while true; do
sleep 1
ps -orss --no-headers --pid $1
done
While OpenJDK allows to monitor the committed RAM inside a code running in JVM, and also you can use standard tools like VisualVM or others.

Memory usage of a program running in two different languages (C#, Java) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I've written a simple program in two different languages, and the result has astonished me!
My application is a simple program (Hello world!).
The C-Sharp program took about 3 MB of RAM, but in Java-FX it was about 78 MB.
Is Java really using that much memory?!
Is there a way to reduce the amount of memory?
Depending on the version of the java virtual machine, the default initial heap size is a reasonable minimum, varies by platform, and can be set at startup. So yes, you can reduce it.
About changing the size and more details: https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gc-ergonomics.html
About the default heap size: How is the default java heap size determined?

How to prevent fragmentation in Java? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have an interview and I was ask how to prevent Memory Fragmentation in Java. Can Anyone summarize how Java deal with it ? I've read some documents but it very complicated.
The short answer is: you use a generational garbage collector.
Except that most modern Java implementations1 use a generational collector by default. In other words, you (the programmer) don't need to deal with the problem because it is already dealt with.
The only situation where you might run into fragmentation is if you have mis-tuned the low-pause collector and it has fallen back to doing a "stop the world" full collection. At that point, you might be using a non-compacting collector, and fragmentation might ensue. But the solution there is to adjust the tuning (or the application, or the heap size) to avoid getting into that situation.
If you want more information about garbage collectors work, there are whole textbooks on the subject. And the various Java collectors are covered in depth in various articles and published research papers.
I've read some documents but it very complicated.
Yes, it is. It is hard work becoming an expert.
1 - Some really old Java implementations used primitive mark-sweep collectors. But they are long gone.

Limit on heap size [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Correct me if I'm wrong, but in the C/C++ heap has no limit, you do not need to pass any argument to increase it.
So why java has a limit on the heap?
There are several reasons:
first you have the minimum heap size, which is there to prevent slow startup
the max heap size is there so that the GC knows when to start doing it's job, without it it would be much harder (but doable, you would just need to take into account different heuristics like number of allocations etc.)
the max heap size also prevents the JVM from hogging all the resources on the machine, which can be a really good thing

Does JVM memory overhead scale linearly, or is it constant? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
In my experience, a C program that uses around 10 megabytes of resident memory may use around 40 to 50 MB when translated into Java, and around 100 in Clojure or Scala. My question is whether this JVM memory overhead scales linearly; if the C version used 1 gigabyte, would the Java version require 4 GB? Or is the JVM memory overhead more a constant factor, such that the 1 GB C program might only use 1.5 GB in Java?
I'm aware that I could benchmark this, but I think hearing people's experience regarding JVM memory use in production would be more informative than an artificial benchmark, which could be skewed to favour either result depending on how it was designed.
The overhead is about 10MB + 4xC-memory.
The 10MB is the JVM without anything. Java 7 64bit version uses about this much.
The 4x memory is obviously a "guesstimate" because it depends on which data types you use. If you use 100% references in java they take up about 4 times as much memory. The same difference there is between int and Integer.
If there are a lot of malloc/new in your C code there will be that in Java too, and Java's GC might not run when you want it to, so there's also an overhead of "dead references not yet cleaned up" that depends greatly on things out of your control (GC timing).

Categories

Resources