Optimizing the Capacity of a HashMap

This article discusses how to optimize memory allocation in HashMaps by understanding the differences between allocation and mapping capacity. It emphasizes the importance of choosing the correct initial capacity, ideally a power of two, to mitigate space overhead and prevent performance degradation. Several formulas for calculating proper capacity are reviewed.

Actions on OutOfMemoryErrors

OutOfMemoryErrors in applications occur when memory allocation fails. This article discusses effective practices for analyzing such errors, including automatic heap dumps and using JVM parameters. It highlights script usage for automatic actions upon encountering errors and emphasizes the importance of proactive monitoring and automated incident reporting to reduce application downtime.

Virtual Threads – A Definite Advantage

Virtual Threads in Java, introduced in version 21, significantly enhance multi-threaded applications by reducing thread management overhead. This article explores their advantages over traditional platform threads through experimentation involving one million threads. Virtual Threads operate efficiently within heap memory, preventing OutOfMemoryError, and allow easier application scalability and performance improvements.

Java Collection Overhead

The Java Virtual Machine enables Java applications to be platform-independent while optimizing performance. One crucial component to understand, when considering performance, especially memory utilization, is how the Java Collections Framework, specifically the ArrayList, handles size and capacity. In this article, we will concentrate on the overhead caused by lists that contain two or three elements.... Continue Reading →

Up ↑