Showing posts with label JDK. Show all posts
Showing posts with label JDK. Show all posts

Wednesday, March 16, 2022

JDK 11 - garbage collector logging

 HOWTO

 

 

GitHub 

* test class  https://github.com/dveselka/java-tutorial/blob/master/src/main/java/gc/LogGC.java

 

GC logs with  timestamp -Xlog:gc*::time

[2022-03-16T22:30:42.734+0100] GC(30) Pause Full (G1 Compaction Pause)
[2022-03-16T22:30:42.734+0100] GC(30) Phase 1: Mark live objects
[2022-03-16T22:30:43.663+0100] GC(30) Phase 1: Mark live objects 929.512ms
[2022-03-16T22:30:43.663+0100] GC(30) Phase 2: Prepare for compaction
[2022-03-16T22:30:43.941+0100] GC(30) Phase 2: Prepare for compaction 277.577ms
[2022-03-16T22:30:43.941+0100] GC(30) Phase 3: Adjust pointers
[2022-03-16T22:30:44.372+0100] GC(30) Phase 3: Adjust pointers 430.642ms
[2022-03-16T22:30:44.372+0100] GC(30) Phase 4: Compact heap
[2022-03-16T22:30:44.748+0100] GC(30) Phase 4: Compact heap 375.878ms
[2022-03-16T22:30:44.751+0100] GC(30) Eden regions: 0->0(99)
[2022-03-16T22:30:44.751+0100] GC(30) Survivor regions: 0->0(13)
[2022-03-16T22:30:44.751+0100] GC(30) Old regions: 1541->1539
[2022-03-16T22:30:44.751+0100] GC(30) Archive regions: 0->0
[2022-03-16T22:30:44.751+0100] GC(30) Humongous regions: 129->129
[2022-03-16T22:30:44.751+0100] GC(30) Metaspace: 3704K(3904K)->3704K(3904K) NonClass: 3407K(3520K)->3407K(3520K) Class: 297K(384K)->297K(384K)
[2022-03-16T22:30:44.751+0100] GC(30) Pause Full (G1 Compaction Pause) 3331M->3330M(3964M) 2017.026ms
[2022-03-16T22:30:44.751+0100] GC(30) User=15.35s Sys=0.02s Real=2.02s
[2022-03-16T22:30:44.751+0100] GC(17) Concurrent Rebuild Remembered Sets 3586.878ms
[2022-03-16T22:30:44.751+0100] GC(17) Concurrent Mark Abort
[2022-03-16T22:30:44.751+0100] GC(17) Concurrent Mark Cycle 5637.293ms
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.base/java.util.HashMap.resize(HashMap.java:702)
    at java.base/java.util.HashMap.putVal(HashMap.java:661)
    at java.base/java.util.HashMap.put(HashMap.java:610)
    at gc.LogGC.main(LogGC.java:15)
[2022-03-16T22:30:44.755+0100] Heap
[2022-03-16T22:30:44.755+0100]  garbage-first heap   total 4059136K, used 3412405K [0x0000000708400000, 0x0000000800000000)
[2022-03-16T22:30:44.755+0100]   region size 2048K, 1 young (2048K), 0 survivors (0K)
[2022-03-16T22:30:44.755+0100]  Metaspace       used 3801K, committed 3968K, reserved 1056768K
[2022-03-16T22:30:44.755+0100]   class space    used 307K, committed 384K, reserved 1048576K

GC logs with -Xlog:gc*

[0.002s][warning][logging] Output options for existing outputs are ignored.
[0.016s][info   ][gc     ] Using G1
[0.019s][info   ][gc,init] Version: 17.0.1+12 (release)
[0.019s][info   ][gc,init] CPUs: 8 total, 8 available
[0.019s][info   ][gc,init] Memory: 15849M
[0.019s][info   ][gc,init] Large Page Support: Disabled
[0.019s][info   ][gc,init] NUMA Support: Disabled
[0.019s][info   ][gc,init] Compressed Oops: Enabled (Zero based)
[0.019s][info   ][gc,init] Heap Region Size: 2M
[0.019s][info   ][gc,init] Heap Min Capacity: 8M
[0.019s][info   ][gc,init] Heap Initial Capacity: 248M
[0.019s][info   ][gc,init] Heap Max Capacity: 3964M
[0.019s][info   ][gc,init] Pre-touch: Disabled
[0.019s][info   ][gc,init] Parallel Workers: 8
[0.019s][info   ][gc,init] Concurrent Workers: 2
[0.019s][info   ][gc,init] Concurrent Refinement Workers: 8
[0.019s][info   ][gc,init] Periodic GC: Disabled


[4.399s][info][gc,heap     ] GC(31) Survivor regions: 12->12(12)
[4.399s][info][gc,heap     ] GC(31) Old regions: 1535->1563
[4.399s][info][gc,heap     ] GC(31) Archive regions: 0->0
[4.399s][info][gc,heap     ] GC(31) Humongous regions: 244->244
[4.399s][info][gc,metaspace] GC(31) Metaspace: 3706K(3904K)->3706K(3904K) NonClass: 3409K(3520K)->3409K(3520K) Class: 297K(384K)->297K(384K)
[4.399s][info][gc          ] GC(31) Pause Young (Normal) (G1 Preventive Collection) 3632M->3637M(3716M) 34.114ms
[4.399s][info][gc,cpu      ] GC(31) User=0.23s Sys=0.01s Real=0.04s
[4.407s][info][gc,start    ] GC(32) Pause Young (Normal) (G1 Preventive Collection)
[4.407s][info][gc,task     ] GC(32) Using 8 workers of 8 for evacuation
[4.429s][info][gc,phases   ] GC(32)   Pre Evacuate Collection Set: 0.2ms
[4.429s][info][gc,phases   ] GC(32)   Merge Heap Roots: 0.1ms
[4.429s][info][gc,phases   ] GC(32)   Evacuate Collection Set: 21.4ms
[4.429s][info][gc,phases   ] GC(32)   Post Evacuate Collection Set: 0.1ms
[4.429s][info][gc,phases   ] GC(32)   Other: 0.1ms
[4.429s][info][gc,heap     ] GC(32) Eden regions: 12->0(80)
[4.429s][info][gc,heap     ] GC(32) Survivor regions: 12->12(12)
[4.429s][info][gc,heap     ] GC(32) Old regions: 1563->1577
[4.429s][info][gc,heap     ] GC(32) Archive regions: 0->0
[4.429s][info][gc,heap     ] GC(32) Humongous regions: 244->244
[4.429s][info][gc,metaspace] GC(32) Metaspace: 3706K(3904K)->3706K(3904K) NonClass: 3409K(3520K)->3409K(3520K) Class: 297K(384K)->297K(384K)
[4.429s][info][gc          ] GC(32) Pause Young (Normal) (G1 Preventive Collection) 3661M->3666M(3716M) 21.847ms
[4.429s][info][gc,cpu      ] GC(32) User=0.14s Sys=0.00s Real=0.02s
[4.430s][info][gc,start    ] GC(33) Pause Young (Normal) (G1 Humongous Allocation)
[4.430s][info][gc,task     ] GC(33) Using 8 workers of 8 for evacuation
[4.443s][info][gc,phases   ] GC(33)   Pre Evacuate Collection Set: 0.1ms
[4.443s][info][gc,phases   ] GC(33)   Merge Heap Roots: 0.0ms
[4.443s][info][gc,phases   ] GC(33)   Evacuate Collection Set: 11.5ms
[4.443s][info][gc,phases   ] GC(33)   Post Evacuate Collection Set: 0.5ms
[4.443s][info][gc,phases   ] GC(33)   Other: 0.1ms
[4.443s][info][gc,heap     ] GC(33) Eden regions: 2->0(93)
[4.443s][info][gc,heap     ] GC(33) Survivor regions: 12->2(12)
[4.443s][info][gc,heap     ] GC(33) Old regions: 1577->1591
[4.443s][info][gc,heap     ] GC(33) Archive regions: 0->0
[4.443s][info][gc,heap     ] GC(33) Humongous regions: 244->244
[4.443s][info][gc,metaspace] GC(33) Metaspace: 3706K(3904K)->3706K(3904K) NonClass: 3409K(3520K)->3409K(3520K) Class: 297K(384K)->297K(384K)
[4.443s][info][gc          ] GC(33) Pause Young (Normal) (G1 Humongous Allocation) 3670M->3672M(3816M) 12.175ms
[4.443s][info][gc,cpu      ] GC(33) User=0.07s Sys=0.00s Real=0.01s
[4.443s][info][gc,ergo     ] Attempting full compaction
[4.443s][info][gc,task     ] GC(34) Using 8 workers of 8 for full compaction
[4.443s][info][gc,start    ] GC(34) Pause Full (G1 Compaction Pause)
[4.449s][info][gc,phases,start] GC(34) Phase 1: Mark live objects
[5.430s][info][gc,phases      ] GC(34) Phase 1: Mark live objects 980.544ms
[5.430s][info][gc,phases,start] GC(34) Phase 2: Prepare for compaction
[5.443s][info][gc,phases      ] GC(34) Phase 2: Prepare for compaction 13.229ms
[5.443s][info][gc,phases,start] GC(34) Phase 3: Adjust pointers
[5.738s][info][gc,phases      ] GC(34) Phase 3: Adjust pointers 295.030ms
[5.738s][info][gc,phases,start] GC(34) Phase 4: Compact heap
[5.756s][info][gc,phases      ] GC(34) Phase 4: Compact heap 17.952ms
[5.785s][info][gc,heap        ] GC(34) Eden regions: 0->0(99)
[5.785s][info][gc,heap        ] GC(34) Survivor regions: 2->0(12)
[5.785s][info][gc,heap        ] GC(34) Old regions: 1591->1541
[5.785s][info][gc,heap        ] GC(34) Archive regions: 0->0
[5.785s][info][gc,heap        ] GC(34) Humongous regions: 244->129
[5.785s][info][gc,metaspace   ] GC(34) Metaspace: 3706K(3904K)->3706K(3904K) NonClass: 3409K(3520K)->3409K(3520K) Class: 297K(384K)->297K(384K)
[5.785s][info][gc             ] GC(34) Pause Full (G1 Compaction Pause) 3672M->3331M(3964M) 1341.941ms
[5.785s][info][gc,cpu         ] GC(34) User=9.83s Sys=0.22s Real=1.35s
[5.785s][info][gc,ergo        ] Attempting maximum full compaction clearing soft references
[5.785s][info][gc,task        ] GC(35) Using 8 workers of 8 for full compaction
[5.786s][info][gc,start       ] GC(35) Pause Full (G1 Compaction Pause)
[5.786s][info][gc,phases,start] GC(35) Phase 1: Mark live objects
[6.797s][info][gc,phases      ] GC(35) Phase 1: Mark live objects 1011.022ms
[6.797s][info][gc,phases,start] GC(35) Phase 2: Prepare for compaction
[7.091s][info][gc,phases      ] GC(35) Phase 2: Prepare for compaction 293.850ms
[7.091s][info][gc,phases,start] GC(35) Phase 3: Adjust pointers
[7.551s][info][gc,phases      ] GC(35) Phase 3: Adjust pointers 460.264ms
[7.551s][info][gc,phases,start] GC(35) Phase 4: Compact heap
[7.967s][info][gc,phases      ] GC(35) Phase 4: Compact heap 416.610ms
[7.971s][info][gc,heap        ] GC(35) Eden regions: 0->0(99)
[7.971s][info][gc,heap        ] GC(35) Survivor regions: 0->0(12)
[7.971s][info][gc,heap        ] GC(35) Old regions: 1541->1540
[7.971s][info][gc,heap        ] GC(35) Archive regions: 0->0
[7.971s][info][gc,heap        ] GC(35) Humongous regions: 129->129
[7.971s][info][gc,metaspace   ] GC(35) Metaspace: 3706K(3904K)->3706K(3904K) NonClass: 3409K(3520K)->3409K(3520K) Class: 297K(384K)->297K(384K)
[7.971s][info][gc             ] GC(35) Pause Full (G1 Compaction Pause) 3331M->3330M(3964M) 2185.032ms
[7.971s][info][gc,cpu         ] GC(35) User=15.44s Sys=0.03s Real=2.18s
[7.971s][info][gc,marking     ] GC(19) Concurrent Mark From Roots 5527.878ms
[7.971s][info][gc,marking     ] GC(19) Concurrent Mark Abort
[7.971s][info][gc             ] GC(19) Concurrent Mark Cycle 5539.567ms
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.base/java.util.HashMap.resize(HashMap.java:702)
    at java.base/java.util.HashMap.putVal(HashMap.java:661)
    at java.base/java.util.HashMap.put(HashMap.java:610)
    at gc.LogGC.main(LogGC.java:15)
[7.973s][info][gc,heap,exit   ] Heap
[7.973s][info][gc,heap,exit   ]  garbage-first heap   total 4059136K, used 3412405K [0x0000000708400000, 0x0000000800000000)
[7.973s][info][gc,heap,exit   ]   region size 2048K, 1 young (2048K), 0 survivors (0K)
[7.973s][info][gc,heap,exit   ]  Metaspace       used 3802K, committed 3968K, reserved 1056768K
[7.973s][info][gc,heap,exit   ]   class space    used 307K, committed 384K, reserved 1048576K

 

Sunday, February 7, 2021

Create Centos 8 Oracle JDK Docker image

HOWTO

 

Download Oracle JDK RPM from https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

 

GitHub repo https://github.com/dveselka/weblogic/tree/master/docker-oracle-java-8

Docker file

 

[dave@dave docker-oracle-java-8]$ more Dockerfile 
FROM centos:8

ADD jdk-8u231-linux-x64.rpm jdk-8u231-linux-x64.rpm

RUN dnf -y  install jdk-8u231-linux-x64.rpm

 

 

Build Docker image 

[dave@dave docker-oracle-java-8]$ docker build -t dveselka/oracle-jdk-8 .
Sending build context to Docker daemon  178.6MB
Step 1/3 : FROM centos:8
 ---> 300e315adb2f
Step 2/3 : ADD jdk-8u231-linux-x64.rpm jdk-8u231-linux-x64.rpm
 ---> e08cec58130d
Step 3/3 : RUN dnf -y  install jdk-8u231-linux-x64.rpm
 ---> Running in edde270eb14b
CentOS Linux 8 - AppStream                      2.8 MB/s | 6.3 MB     00:02    
CentOS Linux 8 - BaseOS                         2.5 MB/s | 2.3 MB     00:00    
CentOS Linux 8 - Extras                          16 kB/s | 8.6 kB     00:00    
Dependencies resolved.
================================================================================
 Package      Architecture Version                     Repository          Size
================================================================================
Installing:
 jdk1.8       x86_64       2000:1.8.0_231-fcs          @commandline       170 M

Transaction Summary
================================================================================
Install  1 Package

Total size: 170 M
Installed size: 294 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Installing       : jdk1.8-2000:1.8.0_231-fcs.x86_64                       1/1 
  Running scriptlet: jdk1.8-2000:1.8.0_231-fcs.x86_64                       1/1 
Unpacking JAR files...
    tools.jar...
    plugin.jar...
    javaws.jar...
    deploy.jar...
    rt.jar...
    jsse.jar...
    charsets.jar...
    localedata.jar...

  Verifying        : jdk1.8-2000:1.8.0_231-fcs.x86_64                       1/1 

Installed:
  jdk1.8-2000:1.8.0_231-fcs.x86_64                                              

Complete!
Removing intermediate container edde270eb14b
 ---> bec32556adc7
Successfully built bec32556adc7
Successfully tagged dveselka/oracle-jdk-8:latest

 

Created image

 

[dave@dave docker-oracle-java-8]$ pwd
/git/weblogic/docker-oracle-java-8
[dave@dave docker-oracle-java-8]$ ls -1
Dockerfile
jdk-8u231-linux-x64.rpm
[dave@dave docker-oracle-java-8]$ docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
dveselka/oracle-jdk-8   latest              bec32556adc7        3 minutes ago       799MB

 

Java inside running container

 

[dave@dave docker-oracle-java-8]$ docker run -it dveselka/oracle-jdk-8
[root@f679c2746165 /]# java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)

[root@f679c2746165 /]# ls -l /usr/java
total 4
lrwxrwxrwx. 1 root root   16 Feb  7 09:53 default -> /usr/java/latest
drwxr-xr-x. 8 root root 4096 Feb  7 09:53 jdk1.8.0_231-amd64
lrwxrwxrwx. 1 root root   28 Feb  7 09:53 latest -> /usr/java/jdk1.8.0_231-amd64
[root@f679c2746165 /]# more /etc/redhat-release 
CentOS Linux release 8.3.2011