Tagged articles
38 articles
Page 1 of 1
macrozheng
macrozheng
Apr 12, 2026 · Backend Development

Why a Simple HashMap Bug Crashed Our High‑Concurrency Service and How to Fix It

A senior architect introduced a high‑concurrency monitoring feature that used ConcurrentHashMap, but missing equals/hashCode and non‑atomic updates caused massive memory leaks and race conditions, leading to a post‑mortem that highlights proper key implementation, atomic map operations, and cautious synchronization.

ConcurrentHashMapMemoryLeakconcurrency
0 likes · 7 min read
Why a Simple HashMap Bug Crashed Our High‑Concurrency Service and How to Fix It
ITPUB
ITPUB
Nov 27, 2025 · Backend Development

Can Renaming Java Fields Really Boost Performance by 37%? A Deep Dive

A popular claim that changing a Java field name from "userName" to "usrNme" can cut API latency by dozens of milliseconds is examined, revealing why hashCode calculations, reflection, and caching have negligible impact compared to real bottlenecks like I/O, GC, and thread scheduling.

ReflectionSpringBoothashcode
0 likes · 5 min read
Can Renaming Java Fields Really Boost Performance by 37%? A Deep Dive
IT Services Circle
IT Services Circle
Nov 24, 2025 · Backend Development

Do Short, Random Field Names Really Speed Up Java? A Deep Dive

A skeptical look at the claim that renaming Java fields to shorter, random names can dramatically improve API latency, examining benchmark data, the actual cost of String.hashCode, reflection mechanics, and the real factors that affect backend performance.

Reflectionbackend-developmenthashcode
0 likes · 5 min read
Do Short, Random Field Names Really Speed Up Java? A Deep Dive
macrozheng
macrozheng
Nov 27, 2024 · Backend Development

How a Tiny HashMap Bug Triggered a Massive Memory Leak in a High‑Traffic Microservice

A senior architect introduced a high‑concurrency monitoring feature that used a ConcurrentHashMap without proper equals/hashCode implementations, leading to duplicate keys, race conditions, and severe memory leaks, which were later resolved by correcting the key class and applying atomic map operations.

ConcurrentHashMapMemoryLeakSynchronization
0 likes · 8 min read
How a Tiny HashMap Bug Triggered a Massive Memory Leak in a High‑Traffic Microservice
The Dominant Programmer
The Dominant Programmer
Jul 19, 2024 · Backend Development

Java Switch Performance: Should You Use String or int?

Using JMH, this article benchmarks Java switch statements, comparing the traditional int‑based switch (via String hashCode) against the newer String‑based switch, showing that the int version runs roughly twice as fast while warning about hashCode collisions.

hashcodeperformanceswitch
0 likes · 6 min read
Java Switch Performance: Should You Use String or int?
Programmer DD
Programmer DD
Aug 14, 2021 · Fundamentals

Why Overriding hashCode() Matters: Java HashSet Gotchas Explained

This article explains the purpose of Java's hashCode() and equals() methods, outlines the rules for overriding them, demonstrates common pitfalls with HashSet through a concrete code example, and clarifies why both methods must be overridden when using custom objects as HashMap keys.

CollectionsHashMapequals
0 likes · 6 min read
Why Overriding hashCode() Matters: Java HashSet Gotchas Explained
Programmer DD
Programmer DD
Jul 23, 2021 · Fundamentals

Why Overriding hashCode Matters: Prevent Memory Leaks and OOM

This article explores the distinction between OutOfMemory errors and memory leaks in Java, examines how improper use of static fields, unclosed streams, incorrect equals/hashCode implementations, and ThreadLocal can cause leaks, and provides practical solutions and tools such as JVisualVM to detect and prevent these issues.

JVMOutOfMemoryThreadLocal
0 likes · 16 min read
Why Overriding hashCode Matters: Prevent Memory Leaks and OOM
Senior Brother's Insights
Senior Brother's Insights
Mar 18, 2021 · Fundamentals

Why Overriding hashCode Is Required When You Override equals in Java

This article explains the relationship between Java's equals and hashCode methods, outlines their contractual requirements, shows how the default implementations work, demonstrates proper overrides with code examples, and provides practical guidelines for implementing robust hashCode functions to ensure correct behavior in hash‑based collections.

HashMapcoding guidelinesequals
0 likes · 11 min read
Why Overriding hashCode Is Required When You Override equals in Java
IT Xianyu
IT Xianyu
Oct 12, 2020 · Fundamentals

Understanding equals() and hashCode() in Java: When They Matter

This article explains the roles of equals() and hashCode() in Java, demonstrates how their interaction affects hash‑based collections like HashSet, provides multiple code examples showing correct and incorrect implementations, and outlines essential principles for overriding these methods to ensure proper object equality handling.

CollectionsObject Equalityequals
0 likes · 9 min read
Understanding equals() and hashCode() in Java: When They Matter
macrozheng
macrozheng
Aug 6, 2020 · Backend Development

When ‘No‑Comment’ Java Code Triggers a Memory Leak – A ConcurrentHashMap Study

A newly hired architect boasts high‑concurrency expertise but writes un‑commented Java code that misuses ConcurrentHashMap, leading to memory leaks; the ensuing investigation reveals missing equals/hashCode implementations, race conditions in a visit method, and a debate between synchronized blocks and putIfAbsent for safe updates.

ConcurrentHashMapSynchronizationbackend-development
0 likes · 8 min read
When ‘No‑Comment’ Java Code Triggers a Memory Leak – A ConcurrentHashMap Study
Programmer DD
Programmer DD
Aug 6, 2020 · Fundamentals

Why Overriding equals Without hashCode Can Cause Memory Leaks in Java

This article explores the distinction between OutOfMemory errors and memory leaks in Java, explains how improper use of static fields, unclosed streams, incorrect equals/hashCode implementations, and ThreadLocal can lead to leaks, and provides practical solutions and tools such as JVisualVM to detect and prevent them.

JVMOutOfMemoryThreadLocal
0 likes · 14 min read
Why Overriding equals Without hashCode Can Cause Memory Leaks in Java
Sohu Tech Products
Sohu Tech Products
May 13, 2020 · Fundamentals

Deep Dive into Java HashMap: Implementation, hashCode/equals, Collision Handling, and Interview Questions

This article provides a comprehensive overview of Java's HashMap, covering its place in the Set and Map families, internal implementation details, the relationship between hashCode() and equals(), collision resolution strategies, basic operations, differences from Hashtable, and several classic interview problems such as Top‑K frequency and LRU cache design.

CollisionData StructuresHashMap
0 likes · 14 min read
Deep Dive into Java HashMap: Implementation, hashCode/equals, Collision Handling, and Interview Questions
Selected Java Interview Questions
Selected Java Interview Questions
Dec 4, 2019 · Fundamentals

Understanding Java HashMap: Implementation Principles, JDK7 Source Walkthrough, and Interview Insights

This article explains the fundamentals of hash tables, dives deep into Java's HashMap implementation—including JDK7 source code analysis of its internal structures, resizing logic, and key methods—while also covering common interview questions such as why the array size must be a power of two and the necessity of overriding both equals and hashCode.

Data StructuresHashMapJDK7
0 likes · 19 min read
Understanding Java HashMap: Implementation Principles, JDK7 Source Walkthrough, and Interview Insights
Architect's Tech Stack
Architect's Tech Stack
Dec 1, 2019 · Fundamentals

Why Java's String.hashCode Uses 31 as Multiplier: Theory and Experiments

This article explores the rationale behind Java's String.hashCode method using the multiplier 31, detailing its implementation, mathematical justification, performance optimizations, and experimental analysis of hash collision rates with various multipliers, concluding why 31 is an optimal choice.

collision analysishashcodeprime multiplier
0 likes · 15 min read
Why Java's String.hashCode Uses 31 as Multiplier: Theory and Experiments
Programmer DD
Programmer DD
Aug 8, 2019 · Backend Development

Why Overriding hashCode and equals Is Critical: Avoid Memory Leaks and Bucket Chaos in Java

This article explains the contract between hashCode() and equals() in Java, shows the problems caused by violating it—such as incorrect behavior in HashMap/HashSet and memory leaks—and provides practical guidelines and code examples for implementing robust hashCode methods, including the use of Apache's HashCodeBuilder.

HashMapImmutable Objectsequals
0 likes · 15 min read
Why Overriding hashCode and equals Is Critical: Avoid Memory Leaks and Bucket Chaos in Java
Java Backend Technology
Java Backend Technology
Jun 11, 2019 · Backend Development

Why Overriding equals Without hashCode Breaks Java Collections

This article explains the contract of equals and hashCode in Java, shows what goes wrong when only equals is overridden, provides a vivid house‑ownership analogy, and offers practical guidelines and code examples for correctly overriding both methods.

Collectionsbackend-developmentequals
0 likes · 5 min read
Why Overriding equals Without hashCode Breaks Java Collections
Java Architect Essentials
Java Architect Essentials
Jul 11, 2018 · Backend Development

Understanding Java HashMap hashCode and Hash Algorithm

This article explains the fundamentals of binary operations, why hashCode is used, how Java's String hashCode is implemented, the rationale behind using the multiplier 31, and the detailed workings of HashMap's hash function, index calculation, capacity choices, and custom sizing recommendations.

Data StructuresHashMaphash algorithm
0 likes · 13 min read
Understanding Java HashMap hashCode and Hash Algorithm
Java Captain
Java Captain
Nov 11, 2017 · Fundamentals

Understanding Java's equals() and hashCode() Methods and How to Override Them

This article explains the default implementations of Java's Object.equals() and Object.hashCode(), the required contracts for overriding them, demonstrates their behavior in the String class, and provides practical guidelines and example code for correctly overriding these methods in custom classes.

HashingOverrideString
0 likes · 11 min read
Understanding Java's equals() and hashCode() Methods and How to Override Them