Category: Java
-
[Java Application Performance and Memory Management] Chapter 10 – Tuning JVM Memory Settings
For tuning JVM settings, we can use below flags -XX:+PrintStringTableStatistics, -XX:StringTableSize=n Updating the String Pool, which can affect the performance of using String. https://willtheguruhome.wordpress.com/2022/02/09/difference-between-string-literal-and-string-object/ -XX:MaxHeapSize=n (same as -Xmxng), -XX:InitialHeapSize=n (same as -Xmsng) Updating the heap size with these flags by like java .. -Xmx1g will enable to set up the…
-
[Java Application Performance and Memory Management] Chapter 9 – Metaspace and the PermGen
All the static variables and general metadata lives in Metaspace area. All the objects on the Heap that are referenced by the static variables in Metaspace will never be garbage collected. Because the static variable is never gone. Before Java 7, it was called as the PermGen. Sometimes when the…
-
[Java Application Performance and Memory Management] Chapter 5 – Passing objects between methods
Passing by Value Passing by Reference – NOT Possible in Java Passing by Value with Objects Final keyword final keyword makes the assignment to happen only once. Generally, using final keyword is good because it allows the Java compiler to potentially optimize the code. However, final keyword doesn’t stop an…
-
[Java Application Performance and Memory Management] Chapter 4 – the stack and the heap
Stack First-In-Last-Out structure. Stores local variables, reference variables, as it lives for short lifetime. It only stores simple data types like primitives(e.g. int, double, ..) . It doesn’t save complex data types like objects. Each Thread has its own Stack Data on a stack cannot be accessed from other threads…
-
[Java Application Performance and Memory Management] Chapter 3- Selecting the JVM
32 bit vs 64 bit Differs per Operating System. 32bit The size of memory pointer is small. The size of memory which is supported by OS is small as well. Might be faster if heap is less than 3GB Only C1 compiler(=Client Compiler) is supported. Application like client application which…
-
[Java Application Performance and Memory Management] Chapter 2- Just In Time Compilation and the Code Cache (2)
C1 compiler and C2 compiler There are two compilers inside the JVM JIT compilers. C1 compiler does level 1~3 compilation, and C2 compiler does the level 4 compilation This level is called as ‘compilation tier‘ The higher the level is, the more optimized the code would be. C2 compiler optimizes…
-
[Java Application Performance and Memory Management] Chapter 2- Just In Time Compilation and the Code Cache (1)
JVM basically runs the compiled Java byte codes(e.g. Main.class). In the early Java system, JVM was running each line of code line by line when it’s needed. Reading line by line of the bytecodes and interpreting it into the machine-readable language was definitely making Java slower than languages like C.…
-
[How Tomcat Works] Chapter 1. HTTP Request, HTTP Response
As web server usually uses HTTP to communicate with the client(e.g. web browser), it is commonly called as HTTP server. Hypertext Transfer Protocol (HTTP) HTTP uses TCP connection which is reliable HTTP transaction always starts when client creates connection first and sends requests Server doesn’t create connection by itself Server…
-
[Effective Java] Item 9 – Prefer try-with-resources to try-finally
It is recommended to use try-with-resources rather than try-finally when we are working with resources that need to be closed as the resulting code is much shorter and cleaner, and the exceptions that is generates are more useful. Usage of try-with-resources Note that we can use catch clause from try-with-resources…
-
[Effective Java] Item 8 – Avoid finalizers and cleaners
What are finalizers and cleaners? Finalizers are the methods that get invoked by JVM garbage collector before the instance gets removed from the memory. From Java 9+, Cleaners are introduced and are just the same as Finalizers but overcome some of the defects of the Finalizers. Usage of finalizers By…
