Topic: General Level: All
1. Low latency
2. High Throughput
3. Efficient resources usage (CPU and memory)
Typical stages involved in the GC are,
1. Mark (Tracing) - the objects are tree represented and from the application root reachable nodes are painted (LIVE) and unreachable (NON-LIVE) are marked for GC.
2. Sweep - Nonlive objects cleared from the heap memory
3. Compact - Live objects are defragmented adjacently to enable free blocks memory for the new objects
4. Copy - Categorization of Live and Nonlive objects for GC
These steps are used in combination by different GC implementations (Serial, Parallel, Concurrent Mark and Sweep, G1, ZGC, Shenandoah)
Further, the GC could process the steps in the below modes as well,
1. Single vs. Multi pass
2. Serial vs. Parallel
3. Stop-the-world vs. Concurrent
Generational heaps determine the Young (Eden & Survivor space) and the Old generation object heaps by frequent GC on Young and tenured on Old. Object becomes eligible for Old gen. transition based on Live set and allocation rate with the JVM arg Xmx specification
https://www.azul.com/blog/what-should-i-know-about-garbage-collection-as-a-java-developer/
1. Same JVM at different time
2. Different Remote JVM
3. Non-JVM Application
Deserialization is the process of recreating the same serialized object in any JVM context.
The widely adopted serialization formats are,
1. XML
2. JSON
Jackson is an external library used for handling Java serialization and deserialization in JSON format. By using the below modules Jackson achieves the context,
1. jackson-core for low-level API streaming and JSON implement
2. jackson-annotations
3. jackson-databind for serialization (transitively supports core and annotation modules)
Jackson ObjectMapper relies on the JavaBean definition of a class,
1. getters for serialization
2. setters for deserialization
Since Jackson is baselined to JDK 7, new features can be incorporated by specifying the registerModule builder method on ObjectMapper.
Jackson annotations can provide custom JSON field names with JsonProperty.
During Deserialization, Jackson requires a default constructor and setters methods on the JavaBean class, however, this is made redundant by JsonCreator on the constructor with JsonProperty on arguments and getters for serialization.
To eliminate the need for external libraries for JSON serialization and deserialization we have JDK 17, record classes.
Combining record classes with sealed classes provides Java native efficient JSON serialization without reflective proxy deserialization can also be attained.
https://blogs.oracle.com/javamagazine/post/java-json-serialization-jackson
The times when the Garbage Collector is not able to free the unallocated/unreachable Java Objects from the heap memory then arises the situation of memory leaks.
The GC will be unable to free the objects if there is at least one reference from the Live set heap memory.
Determining the cause of a leak can be performed by,
1. Heap dump - current heap state and kind of objects present
2. Profiler - how objects are originated
Async-Profiler, measures actual heap allocations with averaged sampling data.
After starting our application, execute the profiler shell script with allow and live args to get the allocation profile data which gives us the heap memory leaks for detection.
https://krzysztofslusarski.github.io/2022/11/27/async-live.html
Consuming a REST endpoint with RestTemplate is straightforward, however, accessing a secured REST endpoint requires configuring the RestTemplate with
1. ClientHttpRequestFactory
2. ClosableHttpClient
3. SSLConnectionSocketFactory
The HTTP communication can be synchronous or asynchronous, as defined by REST web client implementation in Spring.
1. Feign client implementation - Declarative
2. Web client implementation - Reactive
Feign client creates a thread per request model and blocks until a response is received.
The web client is a reactive style model, that sends the request and returns a flux publisher and once the response is received it will be delivered to the subscriber function.
https://www.baeldung.com/spring-boot-feignclient-vs-webclient
The JDK 7 Date API implements the Comparable interface, with comparison returning the difference between the dates (or) the naturalOrder method to return the sorted dates added into a collection via Apache commons DateUtils to add dates to the Date API.
The JDK 8 LocalDate API implements the ChronoLocalDate interface that extends Comparable interface providing compareTo and naturalOrder methods for sorting the dates added via the LocalDate API methods plusXXX().
https://www.baeldung.com/java-max-date-list-streams
- Comments are welcome. However, the blog owner reserves the right to edit or delete any comments submitted to this blog without notice due to :
- Comments deemed to be spam or questionable spam.
- Comments including profanity.
- Comments containing language or concepts that could be deemed offensive.
- Comments containing hate speech, credible threats, or direct attacks on an individual or group.
Comments
Post a Comment