New OpenJDK setting for better memory allocation.

Since -XX:InitialRAMFraction, -XX:MaxRAMFraction, and -XX:MinRAMFraction have been deprecated. Now we changed to

  • -XX:InitialRAMPercentage
  • -XX:MaxRAMPercentage
  • -XX:MinRAMPercentage

Example:

$ java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment Corretto-8.252.09.1 (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM Corretto-8.252.09.1 (build 25.252-b09, mixed mode)
$ free -m
total used free shared buff/cache available
Mem: 3921 462 851 6 2608 3170
Swap: 4091 10 4081
$ java -XX:+PrintFlagsFinal -XX:MaxRAMPercentage=10.0 -version 2>&1 | grep MaxHeapSize
uintx MaxHeapSize := 413138944 {product}
$ java -XX:+PrintFlagsFinal -XX:MaxRAMPercentage=50.0 -version 2>&1 | grep MaxHeapSize
uintx MaxHeapSize := 2057306112 {product}
$ java -XX:+PrintFlagsFinal -XX:MaxRAMPercentage=100.0 -version 2>&1 | grep MaxHeapSize
uintx MaxHeapSize := 4112515072 {product}

Use MaxRAMPercentage=100.0 is such a bad idea , need a free space for NoneHeap too.

Example:

Deployment

containers:
- env:
- name: JAVA_OPTS
value: -XX:InitialRAMPercentage=80.0 -XX:MaxRAMPercentage=80.0 -XX:MinRAMPercentage=80.0
image: tomcat:8-jdk8-corretto
imagePullPolicy: IfNotPresent
name: tomcat
resources:
limits:
memory: 1000Mi

Note:

NGCMX: Maximum new generation capacity (kB).
OGCMX: Maximum old generation capacity (kB).

--

--

--

Very short and simple notes for CKA/SRE and may not works on your environment.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Getting Started with TinyDB in Python

Top Video Chat APIs to integrate into your Video Chat Apps: A Comparative Study!

PYTHON Vs R(The Common Rivalry)

PowerShell script to get all Azure VM status in multiple subscriptions

Regression Testing in Agile — Importance, Strategies and Challenges

Episode 2: “The Holy Grail” — GraalVM (Building “Super Optimum MicroServices Architecture” Series)

Learn Python-100 Days Of Code with Khemlall DAY 4-Randomization and python lists

Computing Society Tutorial: Getting started with Git and GitHub

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jbn1233

Jbn1233

Very short and simple notes for CKA/SRE and may not works on your environment.

More from Medium

[Error]Unable to compile class for JSP

Vlog: Java + Containers = ❤

Lets create a java sample project part 1