Skip to content

Instantly share code, notes, and snippets.

Last active Mar 25, 2018
What would you like to do?

Setup/Uninstall Oracle Java for Mac OS X

Oracle Java install OS X

How to remove Java from my Mac?

# Uninstall Apple Java 6 (
sudo rm -vrf /System/Library/Java/JavaVirtualMachines/1.6.0.jdk
sudo rm -vrf /Library/Java/JavaVirtualMachines/1.6.0*.jdk

# Uninstall Oracle Java JDK/JRE verisons
# - Java 8 (Stable):
# - Java 8 (Early Access Releases):
# - Java 9 (Early Access Releases):
sudo rm -vrf /Library/Java/JavaVirtualMachines/{jdk,jre}*.jdk
sudo rm -vrf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm /Library/PreferencePanes/JavaControlPanel.prefPane

If this is a 64-bit OS, it uses server hydrated JVM option:

And the JVM in server mode if the parameter -Xmx is not specified, it is considered equal to 1/4 of total free memory.

If you specify both the -Xmx and -Xms - then everything will be fine. In RedHat blog recently had an article on the topic of optimization of JVM memory:

Here's another good FAQ


Zoom on java Garbage collector

Date: 2018-02-19 Tags: Java, Gc, Garbagecollector, G1, (C4, Zing), (Shenandoah, RedHat, Epsilongc), Monica, Beckwith, Jvm, Zoomon, (Zgc, Oracle)

Zoom on Java Garbage policy and collectors (in fact just an introduction zoom, lot more to explore around)

Introduction Garbage collector and Garbage policy

A book : "The Garbage Collection Handbook: The Art of Automatic Memory Management (Chapman & Hall/CRC Applied Algorithms and Data Structures series)" To go deeper in the mechanism

Tuning : choose your policy and tune it

"gc tuning confessions of a performance engineer" de Monica Beckwith

Do not forget to get your logs to check impact (take care, big changes with Java 9)

New comers in town

  • Java oracle (Hotspot) G1. Introduced with JDK7 update 4, default Garbage collector on Java 9
  • C4 AzulSystem garbage collector (Zing JVM)
  • Shenandoah (Redhat)
  • ZGC (Oracle)
  • Epsilon GC (experimental)

Redhat G1 presentation :

Zing JVM with C4 (Continuous Concurrent Compacting Collector) GC by AzulSystem

Shenandoah GC (JEP 189) by RedHat

ZGC by Oracle : A Scalable Low Latency Garbage Collector

Epsilon GC : completely passive GC implementation with a bounded allocation limit and the lowest latency overhead possible

JetBrains (JDK 9):

  • -XX:+UseTLAB - Use thread-local object allocation
  • -XX:+ResizeTLAB - Dynamically resize TLAB size for threads
  • -XX:+FastTLABRefill - Use fast TLAB refill code
  • -XX:+AggressiveOpts - Enable aggressive optimizations - see arguments.cpp
  • -XX:+UseStringDeduplication - Use string deduplication
  • -XX:+UseSSE42Intrinsics - SSE4.2 versions of intrinsics
  • -XX:+UnlockExperimentalVMOptions - Enable normal processing of flags relating to experimental
  • -XX:+UseCompressedOops - Use 32-bit object references in 64-bit VM.
  • -XX:+UseCompressedClassPointers - Use 32-bit class pointers in 64-bit VM.
  • -XX:ParallelGCThreads=2 - Number of parallel threads parallel gc will use
  • -XX:+ExplicitGCInvokesConcurrent - A System.gc() request invokes a concurrent collection UseConcMarkSweepGC
  • -XX:+TieredCompilation Enable tiered compilation
  • -XX:+UseAdaptiveGCBoundary - Allow young-old boundary to move
  • -XX:CompileThreshold=100 - number of interpreted method invocations before (re-)compiling
  • -XX:+UseBiasedLocking - Enable biased locking in JVM
  • -XX:SurvivorRatio=8 - Minimum ratio of young generation/survivor space size
  • -XX:TargetSurvivorRatio=90 - Desired percentage of survivor space used after scavenge
  • -XX:+UseFastJNIAccessors - Use optimized versions of Get<Primitive>Field
  • -XX:+UseXMMForArrayCopy - Use SSE2 MOVQ instruction for Arraycopy
  • -XX:AllocatePrefetchStyle=2 - use TLAB watermark to gate allocation prefetch (x86 instructions)
  • -XX:AllocatePrefetchDistance=32 - Distance to prefetch ahead of allocation pointer
  • -XX:+UseAES - Control whether AES instructions can be used on x86/x64
  • -XX:ThreadPriorityPolicy=1
0 : Normal.
    VM chooses priorities that are appropriate for normal
    applications. On Solaris NORM_PRIORITY and above are mapped
    to normal native priority. Java priorities below
    NORM_PRIORITY map to lower native priority values. On
    Windows applications are allowed to use higher native
    priorities. However, with ThreadPriorityPolicy=0, VM will
    not use the highest possible native priority,
    THREAD_PRIORITY_TIME_CRITICAL, as it may interfere with
    system threads. On Linux thread priorities are ignored
    because the OS does not support static priority in
    SCHED_OTHER scheduling class which is the only choice for
    non-root, non-realtime applications.
1 : Aggressive.
    Java thread priorities map over to the entire range of
    native thread priorities. Higher Java thread priorities map
    to higher native thread priorities. This policy should be
    used with care, as sometimes it can cause performance
    degradation in the application and/or the entire system. On
    Linux this policy requires root privilege.

output of java -XX:+PrintFlagsFinal

Young generation collectors

  • Copy (enabled with -XX:+UseSerialGC) - the serial copy collector, uses one thread to copy surviving objects from Eden to Survivor spaces and between Survivor spaces until it decides they've been there long enough, at which point it copies them into the old generation.
  • PS Scavenge (enabled with -XX:+UseParallelGC) - the parallel scavenge collector, like the Copy collector, but uses multiple threads in parallel and has some knowledge of how the old generation is collected (essentially written to work with the serial and PS old gen collectors).
  • ParNew (enabled with -XX:+UseParNewGC) - the parallel copy collector, like the Copy collector, but uses multiple threads in parallel and has an internal 'callback' that allows an old generation collector to operate on the objects it collects (really written to work with the concurrent collector).
  • G1 Young Generation (enabled with -XX:+UseG1GC) - the garbage first collector, uses the 'Garbage First' algorithm which splits up the heap into lots of smaller spaces, but these are still separated into Eden and Survivor spaces in the young generation for G1.




This comment has been minimized.

Copy link
Owner Author

@denji denji commented Feb 23, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment