Understanding Java Heap Memory, Garbage Collection, and Quality Assurance Practices
This article explains Java heap memory concepts, garbage collection mechanisms, common memory issues, and outlines the team's quality assurance framework, including testing left‑shift with AI code review and right‑shift monitoring to improve reliability and performance.
1. Background
Recently the R&D team has been actively handling alerts; a production UMP alert showed that an application’s heap memory usage reached 90.18%, exceeding the 85% threshold, prompting investigation into what heap memory is.
1.1. Java Heap Memory
Definition
Java heap memory is a part of the JVM memory used for dynamic allocation of objects and arrays; it exists from JVM start to shutdown and its size can be adjusted with startup parameters such as -Xms (initial heap size) and -Xmx (maximum heap size).
Characteristics
Dynamic allocation : objects are allocated and freed at runtime.
Automatic management : the JVM’s garbage collector automatically reclaims unused objects.
Global access : any part of the program can reference objects in the heap.
Generational collection : the heap is divided into generations (Young and Old) to optimize GC performance.
Structure
The heap is typically divided into:
Young Generation : contains newly created objects, split into Eden and Survivor spaces (S0, S1). Objects that survive several GC cycles move to the Old Generation.
Old Generation : stores long‑lived objects.
Permanent Generation / Metaspace : holds class metadata; since Java 8 the permanent generation was replaced by Metaspace, which uses native memory.
Working Principle
Object allocation occurs when the new keyword is used. For example, new Person("John", 25) allocates a Person object on the heap.
public class Main {
public static void main(String[] args) {
// Create an object
Person person = new Person("John", 25);
}
}
class Person {
String name;
int age;
// Constructor
Person(String name, int age) {
this.name = name;
this.age = age;
}
}Garbage Collection
The GC automatically reclaims memory of objects that are no longer referenced. Its process generally includes:
Mark: identify all live objects.
Sweep: remove unmarked objects and free their memory.
Compact (optional): move surviving objects to one end of the heap to reduce fragmentation.
Memory Management Issues
Memory leaks : even with GC, improper code can retain references to unused objects, preventing reclamation.
OutOfMemoryError : occurs when the heap is exhausted and GC cannot free enough memory.
Performance problems : frequent GC cycles can degrade application performance, requiring careful tuning.
2. Quality Assurance
2.1. Existing System
2.2. Key Elements
Requirement Quality Dimension
Product releases PRD documents, R&D produces design docs, and testing provides test cases, forming the most direct output of requirements.
Process Quality Dimension
Product, R&D, and testing conduct requirement, design, and test‑case reviews respectively to align understanding and avoid misinterpretations.
Delivery Quality Dimension
Testing issues acceptance reports; product performs requirement acceptance; before release product conducts business acceptance; any issues are fed back for R&D optimization and retesting, forming a loop.
2.3. Quality Control
Environment governance is handled by a dedicated team; Diff&CR belongs to left‑shift testing and will be detailed in improvement measures; monitoring alerts and quality dashboards belong to right‑shift testing.
2.4. Delivery Process
Continuous Iteration
The team follows a two‑week sprint, planning full workloads each iteration.
Continuous Integration
Based on the Coding group’s code repository tool, continuous release is performed; due to special circumstances a custom release system is used instead of the group’s JDOS.
Continuous Operation
A dedicated team is responsible for operations.
Continuous Measurement
An online issue‑handling group uses on‑call coordination; feedback is collected via “Insurance Frontline Voice” and user satisfaction surveys.
2.5. Quality Culture
Quality and efficiency are core team values: “test well and test fast”.
3. Improvement Measures
3.1. Left‑Shift Testing Diff&CR
Traditionally, diff&cr required manual permission to pull branches from the Coding repository, which was inefficient.
Using large‑model‑driven code review (AI‑CR) greatly improves efficiency; the AI can discover hidden risks and enrich bad‑case testing.
3.2. Right‑Shift Monitoring & Alerts
The initial case study showed that some alerts lacked sufficient context, making them hard for non‑technical colleagues to understand; the author refined alert messages to improve clarity.
4. Future Planning
Based on the existing quality‑assurance framework, the team will continue to explore, discover, and optimize to ensure smoother business operation.
JD Tech Talk
Official JD Tech public account delivering best practices and technology innovation.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.