Newsletter #21
Enjoy Newsletter #21.
How to Monitor JVM’s Non-Heap Memory Usage
This Baeldung article surveys tools for monitoring JVM non-heap memory usage—the memory regions outside the heap such as Metaspace, JIT code cache, GC structures, and direct buffers. The simplest option is jcmd: once Native Memory Tracking is enabled, running jcmd <pid> VM.native_memory prints the reserved and committed memory for each region. If you prefer a GUI, jconsole includes a built-in non-heap chart under the Memory tab, while VisualVM displays Metaspace out of the box and can be extended with the MBeans and Buffer Pools plugins to inspect individual regions and direct buffers.
For deeper analysis, Java Mission Control (JMC) lets you inspect total non-heap memory via the MBean Browser (note that this figure excludes direct buffers), and starting in Java 20 you can continuously record Native Memory Tracking events via JFR to track consumption by memory category over time. Finally, the JMX Exporter exposes MemoryMXBean metrics at a Prometheus-compatible /metrics endpoint, integrating non-heap monitoring into existing observability stacks. The author’s rule of thumb: use jcmd or jconsole for quick checks, pair JFR with JMC when you need fine-grained detail, and always account for the resource overhead of the monitoring tools themselves.
Unlocking the Power of Interfaces: Creative Approaches in Java
This Medium post by Real World Java (Gain Java Knowledge) shows that Java interfaces are more than just contracts for classes to implement—they are powerful tools for decoupling components and making code extensible, reusable, and maintainable. The author walks through eight creative uses of interfaces, starting with the Strategy pattern: defining an interface like PaymentStrategy for a family of algorithms and swapping concrete implementations (credit card, PayPal, etc.) at runtime. Next are callback interfaces that allow called code to invoke caller-supplied logic, functional interfaces paired with Java 8 lambda expressions, and mixin interfaces—where a class combines behavior from multiple interfaces to achieve multiple inheritance of behavior.
The remaining sections cover dependency injection through interfaces to reduce tight coupling between classes, the Observer pattern, polymorphism when storing heterogeneous objects in a single collection typed to a shared interface, and default methods that add new functionality to interfaces without breaking existing implementations. For newer Java developers, the post serves as a concise collection of examples showing how interfaces underpin many classic design patterns.
How Java Manages Thread Synchronization with Locks and Monitors
Alexander Obregon explains how Java handles thread synchronization at the JVM level. Every object is associated with an intrinsic lock and a monitor; when a thread enters a synchronized method or block, it must acquire ownership of the monitor while other contending threads wait (the JVM may spin briefly or park the thread depending on contention). The monitor tracks which thread holds the lock, which threads are waiting in the entry set, and which threads are waiting for a signal via wait(), notify(), or notifyAll()—methods that may only be called while holding the lock, or else an IllegalMonitorStateException is thrown. Intrinsic locks are reentrant: a thread that already holds a lock can acquire it again thanks to a recursion counter inside the monitor. To reduce overhead, the JVM uses lightweight locking first and only “inflates” to a full monitor under sustained contention; biased locking was used historically but has been disabled by default since JDK 15.
The second half introduces ReentrantLock in java.util.concurrent.locks, which offers more flexibility than synchronized via tryLock() for non-blocking acquisition attempts, lockInterruptibly() so waiting threads can respond to interrupts, and multiple Condition objects to maintain separate wait queues per condition, such as in a bounded producer-consumer buffer. Under the hood sits AbstractQueuedSynchronizer (AQS), which manages waiting threads using a doubly linked FIFO queue and LockSupport.park(). The article also notes fair locks, which grant access to the longest-waiting thread at the cost of lower throughput, which is why most systems stick with the non-fair default.
Building a Custom Spring Boot Starter for Shared Logic
Alexander Obregon walks through packaging shared cross-cutting logic—such as logging setup, exception handling, or database configuration—into a custom Spring Boot starter instead of copy-pasting it across projects. At the core of a starter is auto-configuration: a class annotated with @AutoConfiguration declares beans alongside conditional annotations like @ConditionalOnMissingBean (backing off if the application defines its own bean) or @ConditionalOnClass (activating only when required classes are on the classpath). Starting in Spring Boot 3, auto-configuration classes are registered in META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports rather than the legacy spring.factories, while @ConfigurationProperties and @EnableConfigurationProperties let consumers customize behavior via application.properties.
The second half covers packaging and publishing. For third-party starters, Spring’s documentation recommends naming modules <name>-spring-boot-starter, reserving the spring-boot prefix for official Spring artifacts. The remaining steps include adding spring-boot-autoconfigure and the configuration metadata annotation processor for IDE autocomplete, running mvn clean install to test locally, and publishing to an internal or public Maven repository. Obregon also advises keeping starters lean and marking non-essential dependencies as optional to avoid version conflicts in consuming applications. Once structured properly, Spring Boot automatically wires everything up on startup.
Real-World Garbage Collection Solutions
This DZone article presents real-world case studies showing how tuning garbage collection (GC) can deliver major performance gains at minimal cost. First, the author outlines the key metrics to watch: throughput (the percentage of time the application spends doing real work, which should be around 99% for critical systems), GC pause latency, CPU time spent in GC, and overall response time. To gather data, enable GC logging with -Xlog:gc*:file=<path> (Java 9+) or -XX:+PrintGCDetails -Xloggc:<path> (Java 8 and earlier) and analyze the logs with a tool like GCeasy.
Three case studies illustrate the impact. An insurance company suffered back-to-back Full GCs during peak hours; adding memory and resizing the heap boosted throughput by 23% and cut GC CPU usage in half. A warehouse robotics control application running CMS on a 126 GB heap experienced occasional pauses lasting up to 5 minutes; switching to G1 brought the worst-case pause down to about 2 seconds with an average of 198 ms. Finally, a cloud service provider running Parallel GC with a 40 GB heap split evenly between young and old generations shrank the young generation to 1 GB, raising throughput to 99% and dropping average pause time from 12 seconds to 139 ms. Takeaway: when a Java application slows down, GC analysis should be your first stop.
Java Naming Conventions
Baeldung summarizes the foundational Java naming conventions that keep codebases readable, consistent, and easy to collaborate on. Classes use UpperCamelCase with nouns or noun phrases that clearly describe their role, like CustomerAccount, avoiding abbreviations or vague names; interfaces also use UpperCamelCase and express the capability implementing classes commit to, such as Printable. Variables use lowerCamelCase, while static final constants use UPPER_SNAKE_CASE like MAX_BALANCE; methods use lowerCamelCase starting with a verb that describes the action, such as deposit() or print(). Variables or methods holding or returning multiple elements should use plural names.
Packages are written in all lowercase using reverse domain name notation—for example, com.baeldung.namingconventions—to organize code cleanly and prevent namespace collisions. Enums use UpperCamelCase for the type name and UPPER_SNAKE_CASE for their constants (such as DayOfWeek.MONDAY), and annotations follow UpperCamelCase just like classes, e.g., @Auditable. While simple, these conventions are essential habits for new Java developers to build early on.
Vibe Coding vs Reality
Cendyne pushes back against the “vibe coding” hype—the viral idea sparked by Andrej Karpathy of “giving in to the vibes” and forgetting the code exists while letting LLMs write everything. The author admits that AI coding agents like Cursor or GitHub Copilot in agent mode look magical when scaffolding a greenfield project from an empty folder, but that excitement quickly fades once the codebase grows. Working with Claude 3.7 Sonnet, Cendyne catalogs a long list of recurring blunders: duplicating TypeScript interfaces instead of importing them, recreating components that already exist, putting security-sensitive trust logic on the client side, mutating production code to match broken tests instead of fixing the tests, refactoring only one instance of duplicated code while leaving the rest untouched, and degenerating into gibberish once the context window fills up.
According to the author, the core limitation is that models cannot genuinely learn new project knowledge on the fly, cannot monitor multiple real-time feedback streams simultaneously (such as server logs alongside end-to-end test output), and lack both short- and long-term organizational memory. The “Claude Plays Pokémon” experiment illustrates how even with handoff notes across context resets, the model keeps repeating the exact same mistakes. The verdict: vibe coding might get you 80% of the way to a prototype, but building reliable, secure software worth paying for still requires experienced humans.
Sell Yourself, Sell Your Work
This short piece on solipsys.co.uk reminds engineers that doing great technical work is not enough on its own: if you lock yourself in a room, produce brilliant work, and never tell anyone about it, nobody knows, nobody benefits, and the effort is effectively wasted. The author has met many talented engineers who avoid writing reports because they find it boring, difficult, and beside the point. In reality, writing and presenting clearly and concisely—since typos or sloppy prose are enough to lose a chunk of your audience—is how your work saves other people time and builds your own credibility.
The post quotes Richard Hamming’s famous 1986 talk “You and Your Research”: finishing a piece of work is not enough—you have to “sell” it, because everyone is busy with their own problems; you must present it well enough that others are willing to set their own work aside to read yours, honing your skills in writing, formal talks, and informal hallway conversations alike. Even if you start your own company, you still have to sell your products and services. The closing message: let the world benefit from the work you do.
Building Resilient Payment Systems at SSENSE: Our Journey Towards Asynchronous Processing
The engineering team at fashion e-commerce platform SSENSE shares how they migrated their payment system from synchronous to asynchronous processing. Their legacy architecture tightly coupled payment execution to the order lifecycle: certain payment service providers (PSPs) processed transactions in batches that left payment status unresolved for hours or even days, flash-sale traffic spikes strained the system, and refunds required complex manual intervention. Their solution was decoupling payment confirmation from order placement—moving orders into a pending state so checkout could proceed—while diversifying across multiple PSPs to reduce single-provider risk.
In the new architecture, the payment service and its cron jobs (written in TypeScript and running on Kubernetes) share a database, receive PSP updates via webhooks, and publish domain events onto an event bus so the order service and financial integration layer can react asynchronously. Every transaction moves through explicit states: Queued, Pending, Complete, Declined, or Failed. When an outbound request fails, the system retries immediately a few times before placing the transaction into Queued for a cron job to replay later, using idempotency keys to prevent duplicate charges. Failed transactions automatically open customer support tickets, and a separate cron job detects transactions stuck in Pending. The result is a smoother checkout experience, greater resilience during peak sales, and consistent data across downstream systems.
This post was rewritten by Claude Code with Opus 5.5 on 27/09/2026; reviewed and edited by Codex with GPT 6.1 Sol on 09/11/2026, and re-verified by Claude Code with Sonnet 5.5 on 16/11/2026.
Comments