跳到主要內容

發表文章

目前顯示的是有「jvm」標籤的文章

Install K8S on VM and spring boot integration.

Installation Environment Vmware Workstation pro  It is recommended to use the  snapshot  to store the state of each installation stage to avoid installation failures and causing the installation to start from scratch. Ubuntu 22.04 windows 11 Hardware settings  create 3 VM: 4 cores and 4G memory and 100G capacity Before installing K8s (All use the root user) set host: 192.168.47.135 master 192.168.47.131 node1 192.168.47.132 node2 set root ssh connection: sudo su - echo "PermitRootLogin yes" >> /etc/ssh/sshd_config systemctl restart sshd sudo passwd ssh-keygen for i in {master,node1,node2}; do  ssh-copy-id root@$i; done set Ipvs and conf  create conf file: for i in {master,node1,node2}; do ssh root@$i 'cat << EOF > /etc/modules-load.d/containerd.conf overlay br_netfilter EOF'; done execute conf: for i in {master,node1,node2}; do ssh root@$i 'modprobe overlay;modprobe br_netfilter;'; done create 99-kubernetes-cri.conf file: for i in {maste...

Class Loading

Class life cycle Class loader reference: https://www.amazon.com/depth-understanding-Java-Virtual-Machine/dp/7111641248

JVM Tools

Table of contents [ hide ]  Java has many useful tools for debugging at runtime or analyzing an application after it has crashed. Commands jps - JVM process Status Tool Same as the Linux command ps, only to find the process under the JVM. jinfo - Configuration Info for Java Show and adjust the JVM arguments. jmap - Memory Map for Java Getting a memory error dump is the most common technique used at runtime. The dump file can be used to analyze the cause of the failure. jstack - Stack trace for Java Check the thread runtime status. GUI VisualVM VisualVM is a tool that provides a visual interface for viewing detailed information about Java applications while they are running on a Java Virtual Machine (JVM). Memory Analyzer (MAT) The Eclipse Memory Analyzer is a fast and feature-rich Java heap analyzer that helps you find memory leaks and reduce memory consumption. reference: https://www.amazon.com/depth-understanding-Java-Virtual-Machine/dp/7111641248 https://en.wikipedia.org/w...

Garbage Collectors

Table of contents [ hide ] The JVM ships with various options for garbage collection to support a variety of deployment options. With this, we get flexibility in choosing which garbage collector to use for our application. Serial GC The Serial collector uses a single thread for garbage collection. The serial collector is not even that powerful compared to other GCs but is useful in a uniprocessor or hardware-constrained environments. ParNew  GC  The parallel version of the Serial collector, before the emergence of G1 GC, the combination of ParNew and CMS worked together, and ParNew was responsible for the garbage collection of the new generation. Parallel Scavenge  GC  Aa a young generation GC, compare to other GCs, focuses on the throughput, and another important feature is the auto adjustment strategy to find the best throughput and pause time. Serial Old GC Serial Old GC is for the old-generation version of Serial GC. It has two purposes, one is to work with...

GC Basic Algorithm

Theory Most GCs follow the theory of generational collection, which is based on the following two: Week generational hypothesis:  Most of the objects are short-living. Strong generational hypothesis:  The more times an object survives GC, the harder it is to die. Mark-Sweep After the marking phase has been completed all space occupied by unvisited objects is considered free and can thus be reused to allocate new objects. There may exist plenty of free regions but if no single region is large enough to accommodate the allocation, the allocation is still going to fail. Mark-Copy To avoid excessive fragmentation, it splits the space into two parts and copies the surviving objects into empty parts. The disadvantage is the need for one more memory region, which should be large enough to accommodate survived objects. Mark-Compact Like mark-copy, it doesn't require another space to copy but a more complex operation to move the object. Reachability analysis First, GC defines some spe...

Java memeory model

The java memory model has multiple areas to do different jobs, this model is in user space because it has no I/O control. There are these parts: Program counter register: For java multi-thread switching different threads, and same functionality as OS counters. (PC) Registers are created every time a new thread is created. The PC holds a pointer to the current statement being executed in its thread. If the currently executing method is 'native', then the value of the program counter register will be undefined. Stack: Private for each thread. It contains method-specific primitive values and references to objects referenced from methods in the heap. Whenever we call a new method, a new block is created on top of the stack which contains values specific to that method Native Method stacks: JVM that supports native methods will have native method stacks. It is used for native methods, and created per thread.  Heap: Heap data area is used to store objects of classes and arrays....

Thread Status

Table of contents [ hide ] The java thread state is similar to the operating system process state, but the java state is in the JVM. Operating system process state New: The process is being created. Ready: The process is waiting to be assigned to a processor. Running: Instructions are being executed. Waiting: The process is waiting for some event to occur(such as an I/O completion or reception of a signal). Terminated: The process has finished execution. Java thread state New:  It represents the first state of a thread that is the NEW state. Runnable:  It represents the runnable state. It means a thread is waiting in the queue to run. Blocked:  It represents the blocked state. In this state, the thread is waiting to acquire a lock. Waiting:  It represents the waiting state. A thread will go to this state when it invokes the Object. wait() method, or Thread.join() method with no timeout. A thread in the waiting state is waiting for another thread to complete ...