This article explains Java's lock mechanisms—including synchronized, ReentrantLock, and their JVM implementations—covers lock classifications, memory barriers, CAS, and compares them with Kotlin coroutine synchronization tools like Mutex, providing code examples and practical guidance for safe concurrent programming.
This guide explains how to launch Java processes from the command line, details key JVM tuning flags such as -X and -XX options, describes garbage collection algorithms, reference strengths, and stop‑the‑world pauses, providing practical examples and diagrams to help developers optimize memory usage and performance.
This tutorial explains the differences between Java's System.exit() and Runtime.getRuntime().halt(), detailing their shutdown sequences, impact on shutdown hooks and finalizers, providing code examples and test cases, and offering guidance on when to use each method safely.
Discover twelve practical SpringBoot performance optimization techniques—from connection pool tuning and JVM memory settings to caching, async processing, and full‑stack monitoring—each illustrated with code snippets and actionable guidance to prevent full‑table scans, OOM errors, and latency spikes in high‑traffic applications.
This article explains what JVM thread dumps are, why they are crucial for fault testing, outlines common scenarios such as deadlocks and resource leaks, and provides step‑by‑step methods—including jstack, kill‑3, VisualVM, programmatic APIs, and Fabric8‑driven Kubernetes automation—to capture and analyze them effectively.
The article explains how to achieve graceful shutdown of Spring Boot services by handling Linux kill signals, registering JVM shutdown hooks, and exposing an Actuator REST endpoint that safely releases resources, stops beans, and terminates the JVM without data loss.
When a midnight CPU alarm triggered, I logged into the server, identified runaway Java processes, profiled the JVM, refactored a costly sorting algorithm, added database indexes, containerized the service, and set up Prometheus alerts, ultimately reducing CPU usage below 30% and restoring millisecond response times.
When a midnight CPU alarm threatened service availability, I walked through rapid system checks, JVM profiling, algorithm refactoring, database indexing, Docker isolation, and Prometheus alerting to bring CPU usage back below 30% and restore millisecond‑level response times.
After caching, indexing, and async optimizations still leave a Spring Boot REST API sluggish, this guide shows how fine‑tuning JVM options—such as enabling G1GC, adjusting pause targets, compressing class metadata, shrinking thread stacks, and pre‑touching memory—can triple response speed without changing application code.
Facing frequent timeouts in a high‑throughput Java service, we traced instability to long GC pauses during massive index swaps, then systematically tuned JVM parameters, explored G1, ZGC, and custom Eden‑pre‑heating techniques, ultimately achieving near‑perfect availability without adding hardware.
This article introduces the SootUp library, explains how to configure its Maven dependencies, describes the Jimple intermediate representation, and demonstrates how to use SootUp's API to analyze Java source code, bytecode, and method bodies through a series of code examples.
This article compares the compilation and runtime processes of C and Java programs, explains Java's class loading, linking, initialization, memory layout, execution engine components, and native interface, and highlights why Java startup is slower than native C execution.
This article uses real‑world analogies to dissect the three core challenges of Java concurrency—ordering, visibility, and atomicity—and explains how hardware instructions, JVM mechanisms, and Java SDK tools such as locks, CAS, and waiting/notification utilities provide efficient solutions.
This article humorously introduces a common interview scenario and then provides a comprehensive overview of JVM garbage collection, covering memory regions, GC roots, collector types like ParNew, G1, CMS, tuning parameters, code examples, and practical tips for diagnosing and optimizing GC behavior.
This article explains the concept of Java's Runtime.addShutdownHook, details its underlying implementation in the Runtime and ApplicationShutdownHooks classes, demonstrates usage with code examples, discusses typical application scenarios, potential risks of long‑running hooks, and provides best‑practice recommendations for safe JVM shutdown handling.
This article explains the purpose and inner workings of Java's Runtime.addShutdownHook, walks through the Runtime and ApplicationShutdownHooks source code, demonstrates practical usage with examples, discusses common scenarios, potential risks, and best‑practice solutions for reliable resource cleanup during JVM shutdown.
The article lists the most frequent Java OutOfMemoryError variants, explains their root causes and typical scenarios, provides concrete code examples that trigger each error, and offers practical troubleshooting steps and JVM tuning recommendations for interview preparation.
A friend who landed a 16K job in a first‑tier city shares more than 30 interview questions he encountered across ten+ companies, covering JVM internals, performance tuning, concurrency, design patterns, database locking, distributed transactions, and system reliability.
This article explores the puzzling "prevent gc" comment in RocketMQ source code, explains how Thread.sleep(0) interacts with JVM safepoints, distinguishes counted and uncounted loops, and demonstrates practical experiments that reveal why altering loop variables can change GC behavior.
This article explains why the JVM throws java.lang.OutOfMemoryError: GC overhead limit exceeded, outlines common causes such as traffic spikes, memory leaks, insufficient heap and inefficient GC, and provides practical solutions and debugging steps to diagnose and fix the issue.
java.lang.OutOfMemoryError: Requested array size exceeds VM limit occurs when a Java program attempts to allocate an array larger than the JVM's available heap, and can be mitigated by increasing heap size, optimizing code, or processing data in smaller batches.
The article presents a Spring Boot experiment measuring per‑request heap memory usage for HTTP and RPC calls, details the JMeter test setup, analyzes GC logs, reports findings such as ~34KB per HTTP request and 0.5‑1MB per RPC request, offers optimization recommendations, and also includes promotional material for AI‑related products.
This article examines why storing phone numbers as Java Strings rather than ints yields better memory usage, semantic correctness, and JVM-level performance, discussing primitive vs reference types, bytecode differences, string pooling, and real‑world case studies.
java.lang.OutOfMemoryError: Metaspace occurs when the JVM's native Metaspace exceeds its configured limit, often due to excessive dynamic class generation, large numbers of loaded classes or classloader leaks, and can be mitigated by increasing Metaspace size, fixing memory leaks, and optimizing class loading.
This article explains the Java memory pool model, common Out‑of‑Memory errors, their root causes, tuning parameters, and real‑world case studies to help developers diagnose and resolve OOM issues in containerized Java applications.
This article explains the JVM method area concept, its implementation as the permanent generation in JDK 1.7, the limitations of that approach, and how JDK 1.8 introduced metaspace using native memory to improve class metadata management and avoid out‑of‑memory errors.
When a midnight CPU alarm threatened a core Java service, I walked through rapid system checks, JVM profiling, algorithm refactoring, database indexing, Docker isolation, and enhanced monitoring to bring CPU usage back below 30% and restore service stability.
This article explains Java virtual threads introduced by Project Loom, compares them with platform threads in terms of memory usage and creation time, provides code examples for creating and managing virtual threads, and outlines practical guidelines and use‑cases for high‑concurrency backend applications.
This article explains Java's dynamic ClassLoader mechanism, outlines the hierarchy of built‑in loaders, details frequent problems such as ClassNotFoundException, NoClassDefFoundError, ClassCastException and version conflicts, and provides practical troubleshooting steps and best‑practice recommendations for reliable class loading.
This article explains how the java.lang.ClassLoader#loadClass() API works, why frequent concurrent calls can cause thread blocking due to internal synchronization, demonstrates the issue with a sample multithreaded program, analyzes thread‑dump data, and provides practical solutions to mitigate the performance problem.
This article explains why Spring Boot applications can consume up to 12 GB of RAM, demonstrates how to inspect JVM memory with tools like jps and jmap, clarifies default heap size calculations, and provides practical steps to tune JVM parameters for production stability.
This article explains the low‑level implementation of Java's synchronized keyword, covering monitorenter/monitorexit bytecode, object header structures, Mark Word layouts, and the evolution from heavyweight locks to biased and lightweight locks with lock‑upgrade mechanisms.
This article explains the JVM's tiered compilation mechanism, detailing the client (C1) and server (C2) JIT compilers, the five compilation levels, code cache organization, relevant JVM flags, and demonstrates method compilation lifecycle through illustrative Java code examples and log analysis.
An in‑depth look at how the JVM stores object references, comparing handle‑based access with direct pointer access, highlighting their performance trade‑offs, memory overhead, and impact on garbage collection to help developers choose the most suitable approach for their applications.
This article explains how to size and configure JVM options—including heap size, young generation, GC algorithm, thread stack, and metaspace—for a backend service that processes one million login requests per day on an 8 GB machine, providing step‑by‑step calculations, practical examples, and optimization tips.
This curriculum outlines a 25‑week advanced Java engineering program covering performance optimization, JVM internals, concurrency, distributed storage, MySQL and NoSQL databases, Docker, Kubernetes, microservices, Spring framework deep dives, Nginx, Elasticsearch, Redis, messaging systems, CI/CD tools, and hands‑on project implementation to build high‑performance, scalable backend systems.
This article explains the CRaC (Coordinated Restore at Checkpoint) technology for Java applications, describing its principles, supported environments, practical steps for enabling it with Spring Boot, and use‑case scenarios that dramatically reduce JVM startup time.
The article explains the concept of GC Roots in the JVM, detailing the four main types—stack variables, static fields, constant pool references, and JNI references—along with code examples, and describes how these roots determine object liveness during garbage collection.
This article walks through a step‑by‑step troubleshooting process for JVM Out‑Of‑Memory (OOM) incidents, covering symptom identification, monitoring tools like top, jstat, and jmap, root‑cause analysis, and actionable recommendations to prevent future memory leaks.
This article explains the main Java garbage collection algorithms—Mark‑Sweep, Mark‑Copying, Mark‑Compact, and Generational Collection—detailing their principles, advantages, and drawbacks, helping developers choose the appropriate strategy for efficient memory management in backend applications.
This article explains the core principles of Java class loading, including the uniqueness of Class objects per ClassLoader, various loading sources such as dynamic generation, network, ZIP archives, and databases, the lifecycle stages, delegation model, isolation, and practical recommendations for safe and efficient deployment.
This article explains the structure, contents, and characteristics of Java's Class constant pool and runtime constant pool, detailing how literals and symbolic references are stored, how the runtime pool can be dynamically modified, and the impact on memory and JVM linking.
The CMS (Concurrent Mark Sweep) garbage collector, designed for low‑latency old‑generation reclamation, suffers from memory fragmentation, floating garbage, high CPU usage, concurrent‑mode failures, Full GC risks, and complex tuning, making it unsuitable for many production Java workloads.
Because phone numbers are identifiers that can contain symbols and exceed the numeric range of an int, storing them as a String—despite higher memory use—is semantically correct, avoids overflow, preserves formatting, and benefits from JVM string pooling, making String the preferred type in most Java applications.
This article analyzes the trade‑offs between using int and String to store phone numbers in Java, covering type characteristics, the semantic nature of phone numbers, JVM bytecode implications, performance considerations, and practical case studies to guide developers toward the optimal choice.
The article examines the trade‑offs of using Java's primitive int versus the String class to store phone numbers, covering memory usage, JVM bytecode behavior, data semantics, and practical performance implications for large‑scale systems.
This article explains why using Java's String type for phone numbers is more memory‑efficient, semantically correct, and performant than using primitive int, covering JVM bytecode, memory layout, string pool optimization, and real‑world case studies.
This article explains the Java memory model, outlines common OutOfMemoryError types, and provides a step‑by‑step guide for diagnosing, fixing, and preventing memory‑related issues in large‑scale Java applications, including heap, metaspace, and stack analysis, JVM flag tuning, and best‑practice recommendations for resource handling and monitoring.
This article investigates whether the JVM terminates when a thread encounters an OutOfMemoryError, demonstrating through Spring Boot controllers and multithreaded examples how main and child threads, daemon settings, and explicit OOM handling affect JVM shutdown behavior.
This article explains Java's ClassLoader mechanism, its loading, linking, and initialization phases, the parent‑delegation hierarchy, common problems such as ClassNotFoundException and OOM, and provides practical troubleshooting steps and best practices for managing dynamic class loading.
The program that loops on a non‑volatile boolean flag sometimes terminates because changing the counter to a volatile int or to an Integer causes the JVM to emit hidden memory barriers on reference writes, making the flag visible, but this behavior is JVM‑specific and not a reliable substitute for declaring the flag volatile.
This article details a SpringBoot experiment using JMeter to measure the heap memory allocated per HTTP request, analyzes GC logs, and discusses how request size and logging affect memory consumption, providing practical JVM tuning insights for backend developers.
This article explains the Concurrent Mark Sweep (CMS) garbage collector, detailing its five phases—Initial Mark, Concurrent Mark, Remark, Concurrent Sweep, and Concurrent Reset—while highlighting how each step works to minimize pause times during old‑generation memory reclamation in Java.
This article examines the drawbacks of using Java's primitive int type to store phone numbers, explains how primitive and reference types differ in memory and performance, and demonstrates why the String type, with JVM optimizations like the string pool, provides a safer, more flexible solution for global telephone data.
This article explains how to create custom Java class loaders by extending java.lang.ClassLoader, when to override findClass versus loadClass, demonstrates both adhering to and breaking the parent delegation model with complete code examples, and discusses common scenarios such as web servers, SPI, and hot deployment where the delegation mechanism is intentionally altered.
This article explains Java's class loading mechanism, the three built‑in class loaders, the parent‑delegation model, reasons for using it, how to create custom loaders, and the detailed phases of loading, linking, initialization, usage, and unloading.
This article explains the Java Virtual Machine's two subsystems—Class Loader and Execution Engine—and its two main components—Runtime Data Area and Native Interface—detailing their functions, internal structures, and the overall execution workflow of Java programs.
This article walks through a systematic, eight‑step approach to sizing and configuring JVM memory parameters—including heap, young generation, stack, object age thresholds, and garbage‑collector selection—so that a service handling one million daily logins on an 8 GB machine can achieve stable performance and predictable GC behavior.
This article explains common interview questions on frequent Full GC and high CPU usage in Java backend development, detailing root causes, JVM parameter adjustments, memory leak prevention, and code optimization techniques, along with practical code examples and tool recommendations for effective performance tuning.
This article documents a step‑by‑step investigation of a Java 11 application that suffered OS‑level OOM despite a 4 GB heap, revealing that multiple Netty PooledByteBufAllocator instances loaded by different class loaders consumed far more native memory than expected.
This article recounts a production incident where Spring Boot services consumed excessive memory, explains how to diagnose the issue using jps and jmap, discusses default JVM heap settings, offers practical remediation steps, and also contains promotional material for AI community services and related offers.
This article presents a comprehensive collection of written‑test and interview questions covering Java basics, Spring MVC annotations, JVM memory, garbage collection, database design, transaction management, distributed systems, version control, and development workflow, aimed at helping candidates prepare for small‑company technical interviews.
This article details a practical experiment using SpringBoot 2.5.4 and JMeter to measure the heap memory allocated by individual HTTP and RPC requests, analyzes GC logs, and demonstrates how request size and logging affect memory consumption, providing insights for backend performance optimization.
This guide explains why Tomcat's default development settings need tuning for production, covering JVM memory model basics, configuration file edits, thread pool and connector adjustments, as well as security hardening steps to improve performance and stability.
This article walks readers through upgrading from Java 11 to the Java 21 LTS by explaining the six‑month release cadence, JEP process, and SDKman setup, then demonstrates practical code examples for twelve new features—including preview Unnamed Classes, String Templates, Scoped Values, Structured Concurrency, Vector API, Virtual Threads, and Generational ZGC—highlighting their motivations, benefits, and production considerations.
This article breaks down Java's three memory regions—Heap, Off‑Heap, and No‑Heap—detailing their definitions, management mechanisms, performance impacts, typical use cases, and provides concrete code samples for allocating each type of memory.
The article explains JVM garbage‑collection techniques, comparing simple reference‑counting and reachability analysis, then details the three‑color marking algorithm—including its phases, color semantics, step‑by‑step process, and common issues like over‑marking and under‑marking—followed by solutions used in CMS and G1 collectors.
This guide explains how to optimize Tomcat by adjusting maxThreads, acceptCount, maxConnections, and connectionTimeout, while also tuning Linux kernel parameters, TCP settings, and JVM options to achieve balanced CPU and I/O performance for high‑concurrency web services.
This article presents an overview of Kuaishou's system software team, detailing its core value, challenges, the "Four Horizontal Four Vertical" architecture, JVM innovations such as transparent coroutines and checkpointing, advanced compilation techniques, kernel isolation for cloud‑native workloads, and extensive performance‑boosting strategies that have dramatically improved resource utilization and stability.
The article investigates a mysterious "prevent gc" comment in RocketMQ's source, explains how Thread.sleep(0) forces a JVM safepoint to mitigate long GC pauses, and demonstrates that changing loop counters from int to long eliminates the need for the hack.
A senior developer recounts switching from C# and Python to Java for web projects and higher pay, illustrating Java’s evolution from a “toy” language with early JVM limits to an enterprise powerhouse driven by JIT, Spring Boot, and robust performance that now rivals C++.
This article explains how the i++ and ++i operators are implemented at the JVM bytecode level, using concrete code examples and step‑by‑step analysis of each instruction to show why i++ can output 8 while ++i yields 9.
This article explains how Java's garbage collectors work, covering generational memory spaces, major algorithms such as mark‑sweep, mark‑compact, and copy, the most common collectors for young and old generations, safe points, throughput calculations, and tuning parameters.
This guide walks through identifying Java processes that cause high CPU load, extracting the hottest threads with top and jstack, analyzing JVM memory regions, interpreting GC logs, and applying practical JVM tuning parameters and tools such as jmap, jstat, and MAT to resolve performance bottlenecks.
This article presents a systematic experiment that uses JMeter to generate HTTP requests against a SpringBoot 2.5.4 service, records detailed GC logs, and calculates that each HTTP call consumes roughly 34 KB of heap memory, while logging and payload size can significantly increase the allocation.
Java’s ubiquitous NullPointerException stems from Tony Hoare’s 1965 introduction of the null reference—a design he later called his ‘billion-dollar mistake’—and the JVM mitigates its cost by forgoing proactive checks, instead relying on OS signals like SIGSEGV to detect nulls and throw the exception only when they actually occur.
This article explains how to plan capacity, choose the appropriate garbage collector, allocate heap and non‑heap memory, and configure JVM flags—including Xms, Xmx, Xmn, Xss, and GC‑specific options—to reliably support a service node with 8 GB RAM handling one million login requests per day.
This article explains Java’s constant pools, detailing the class constant pool stored in .class files, its transformation into the runtime constant pool during JVM loading, and the specialized string constant pool that optimizes memory usage, including recent changes moving it to heap memory.
This article recounts a production incident where Spring Boot services consumed excessive memory, details step‑by‑step diagnostics using jps and jmap, explains default JVM heap settings, offers remediation recommendations, and also includes promotional material for AI services.
This article recounts a midnight CPU alert incident and walks through systematic backend troubleshooting—from initial system checks and JVM profiling to algorithm refactoring, database indexing, Docker‑based isolation, and proactive monitoring—demonstrating how to restore service performance and prevent future outages.
This article investigates the common belief that Java try‑catch blocks severely degrade performance by examining JVM exception handling mechanisms, bytecode generation, JIT and AOT compilation effects, and presenting detailed benchmark tests under various JVM modes.
After upgrading core services to JDK 11, the team encountered a Metaspace rise and off‑heap memory growth caused by class‑loading changes and Netty’s disabled native buffers, which were resolved by expanding Metaspace to 768 MB and adding JVM options to enable Netty reflection and open required modules, restoring normal memory usage.
Java 21's virtual threads provide lightweight, high‑concurrency execution managed by the JVM, and this article explains their fundamentals, demonstrates basic creation, shows how to enable them in Spring Boot, and presents performance benchmarks comparing virtual threads to traditional threads.
This article demonstrates how to experimentally determine the heap memory allocated by individual HTTP and RPC requests in a SpringBoot application using JMeter load testing, GC logging, and code analysis, providing insights into memory consumption, GC frequency, and optimization strategies for backend performance.
This article explains how Java classes are loaded into the JVM, details the class loader’s parent‑delegation mechanism, and walks through the execution flow of a sample program, covering stack frames, heap allocation, dynamic linking, method area, program counter, native method stack, and garbage collection.
This article explores Java's class loading mechanism in depth, covering when and how classes are loaded, the parent‑delegation model, the internal role of ClassFileParser and InstanceKlass, parallel loading nuances, and practical ways to break or extend the delegation chain with custom class loaders.
This article details a real‑world case where Spring Boot microservices on a 64 GB server consumed excessive memory, explains how to diagnose the issue using jps and jmap, discusses default JVM heap settings, and provides practical recommendations for tuning JVM parameters to prevent similar problems.
The article explains Elasticsearch's on‑heap and off‑heap memory design, details each memory pool and its management via LRU, describes Lucene's role in off‑heap storage, and provides practical tips for configuring JVM heap size, cache strategies, and monitoring to achieve stable, high‑performance search.
Chief designer Michail Zarečenskij explains Kotlin’s evolution from a Java alternative to a multiplatform language, its ongoing reliance on JVM interoperability, hopes for Project Valhalla, the impact of Project Loom on coroutines, and upcoming features slated for the next Kotlin release.
This article walks through a systematic approach to sizing and configuring JVM parameters—including heap size, young generation, GC algorithm selection, and advanced options—for a high‑traffic login service that processes one million requests per day on a server with 8 GB of memory, while explaining the underlying performance‑analysis methodology.
This article compares coroutines and threads for high‑concurrency and I/O‑intensive workloads, summarizes multithreading fundamentals, presents performance‑critical code examples, and discusses JVM memory, locking, middleware, and various optimization techniques for backend systems.
This article records and reviews a production incident where multiple Spring Boot services consumed excessive memory, explains how default JVM settings caused each instance to allocate up to 12 GB of heap, and provides step‑by‑step diagnostics, configuration guidelines, and optimization recommendations for backend developers.
This article examines a Java micro‑benchmark that measures object creation time, explains why printing objects dramatically slows execution, and details JVM allocation strategies such as stack allocation, escape analysis, scalar replacement, and Thread‑Local Allocation Buffers (TLAB) with relevant parameters.
This article explains, step by step, how to estimate capacity, choose the appropriate garbage collector, size the young and old generations, configure stack memory, adjust object aging thresholds, and fine‑tune CMS or G1 settings so that a Java service handling one million daily logins can run reliably on an 8 GB node.
The article details a SpringBoot experiment that uses JMeter to send 20,000 HTTP requests, captures detailed GC logs, and demonstrates that each request consumes roughly 34 KB of heap memory, with larger payloads and logging increasing the usage, highlighting the importance of memory‑aware coding and log management.
This article introduces AviatorScript, a lightweight high‑performance expression engine and scripting language for the JVM (including Android), outlines its core features, demonstrates basic expression evaluation, variable handling, built‑in and custom functions, and shows how to run full scripts with code examples.
This article explains how to analyze per‑second object memory usage in a 100k TPS e‑commerce order flow, choose an appropriate garbage collector, set heap and young‑generation sizes, and apply common JVM tuning parameters to reduce Full GC pauses and improve latency and throughput.
This article debunks the myth that Java try‑catch blocks severely degrade performance by explaining JVM exception handling, showing bytecode differences, presenting benchmark code, and reporting test results under interpreter and JIT modes, concluding that the impact is negligible when no exception occurs.
This article explains the three-part structure of a Java object in the HotSpot JVM—object header, instance data, and alignment padding—detailing the Mark Word and Klass Pointer fields, their bit‑level layout, and how they affect memory size, GC age, and locking behavior.