Published:   Updated:   MyRobot

🎯 Master Java memory leak detection through the complete Detect β†’ Analyze β†’ Refactor β†’ Verify workflow with the Spring Boot memory leak demo


πŸ“š Course Structure

  • Module 1: Foundations - 2 hours (Focus: Memory leak theory and setup; Key learning: Understanding leak patterns; profiling infrastructure)
  • Module 2: Detect - 3 hours (Skill: 161-java-profiling-detect; Focus: Problem-driven data collection; flamegraph and JFR evidence)
  • Module 3: Analyze - 2 hours (Skill: 162-java-profiling-analyze; Focus: Evidence documentation; Impact/Effort prioritization)
  • Module 4: Refactor - 2 hours (Skill: 163-java-profiling-refactor; Focus: Trusted analysis; targeted resource lifecycle fixes)
  • Module 5: Verify - 1 hour (Skill: 164-java-profiling-verify; Focus: Controlled before/after comparison; regression detection)

Total Duration: 8-12 hours (depending on learning path)

πŸ“š Course details

Module 1: Memory Leak Foundations and Detection Setup (2 hours)

Learning Focus: Understanding memory leaks and setting up detection infrastructure

Key Topics:
- What are memory leaks and why they matter?
- Types of memory leaks in Java applications
- Introduction to the Spring Boot memory leak demo
- Setting up profiling infrastructure with the detection skill
- Understanding the coco=true/false configuration pattern

Hands-on Activities:
- Explore the CocoController vs NoCocoController implementations
- Set up profiling scripts using 161-java-profiling-detect
- Run initial baseline profiling session

Learning Outcomes:
- Identify different types of memory leak patterns
- Set up automated profiling environment
- Understand the demo application architecture


Module 2: Detect and Collect Profiling Evidence (3 hours)

Learning Focus: Using 161-java-profiling-detect to collect problem-driven profiling data

Key Topics:
- Deep dive into the 161-java-profiling-detect Agent Skill
- Interactive profiling script walkthrough (21 profiling options)
- Trusted, preinstalled async-profiler v4.x setup
- Memory leak detection strategies (5-minute vs 30-second profiles)
- JMeter load testing integration for realistic scenarios
- Understanding flamegraph interpretation

Hands-on Activities:
- Execute memory allocation profiling (Option 2)
- Run memory leak detection workflow (Option 8)
- Generate JMeter load tests for consistent profiling conditions
- Create comprehensive memory analysis workflow (Option 9)

Learning Outcomes:
- Master the interactive profiling script
- Generate meaningful profiling data under load
- Interpret flamegraph visualizations effectively


Module 3: Analyze Profiling Evidence (2 hours)

Learning Focus: Systematic analysis using 162-java-profiling-analyze

Key Topics:
- Systematic analysis framework for profiling data
- Problem categorization and severity assessment
- Evidence documentation with quantitative metrics
- Cross-correlation analysis techniques
- Impact vs Effort prioritization framework

Hands-on Activities:
- Analyze flamegraphs to identify memory leak patterns
- Create problem analysis documents following templates
- Develop prioritized solution recommendations
- Document evidence with specific file references

Learning Outcomes:
- Systematically analyze profiling results
- Create structured documentation for findings
- Prioritize fixes using Impact/Effort scoring


Module 4: Refactor from Profiling Evidence (2 hours)

Learning Focus: Using 163-java-profiling-refactor to implement targeted fixes from trusted analysis findings

Key Topics:
- Understanding the coco=false refactoring strategy
- Thread pool lifecycle management
- Bounded collections implementation
- Resource cleanup patterns (@PreDestroy)
- Deployment verification procedures

Hands-on Activities:
- Review repository-owned profiling problem and solution documents
- Switch from CocoController to NoCocoController
- Verify code changes are properly applied
- Implement monitoring and alerting
- Test application stability after refactoring

Learning Outcomes:
- Apply evidence-driven, targeted refactoring strategies
- Implement proper resource management patterns
- Validate refactoring through the project test suite


Module 5: Verify Profiling Improvements (1 hour)

Learning Focus: Using 164-java-profiling-verify to validate improvements

Key Topics:
- Before/after comparison methodology
- Quantitative metrics extraction
- Visual flamegraph comparison techniques
- Success criteria validation
- Documentation of improvements

Hands-on Activities:
- Generate post-refactoring profiling reports
- Perform side-by-side flamegraph comparison
- Create comparison analysis documentation
- Validate performance improvement targets

Learning Outcomes:
- Rigorously validate performance improvements
- Document quantified results
- Establish ongoing monitoring strategies


πŸ› οΈ Tools and Technologies

Primary Tools:

  • async-profiler v4.x: Advanced profiling with flamegraph generation
  • JFR (Java Flight Recorder): Low-overhead continuous profiling
  • JMeter: Load testing for realistic profiling scenarios
  • Spring Boot Actuator: Application monitoring and health checks

Profiling Agent Skills:

  • 161-java-profiling-detect: Trusted profiler setup and problem-driven data collection
  • 162-java-profiling-analyze: Evidence analysis, documentation, and prioritization
  • 163-java-profiling-refactor: Targeted code changes based on trusted analysis
  • 164-java-profiling-verify: Controlled before/after comparison and regression detection

The 151-java-performance-jmeter skill can complement the workflow when a reproducible load test must be created or improved.

Visualization Techniques:

  • Flamegraphs: Call stack and allocation visualization
  • Heatmaps: Temporal analysis of performance hotspots
  • Memory usage charts: GC retention and heap growth patterns
  • Thread dumps: Concurrency and threading analysis

πŸ› οΈ Four-Skill Profiling Workflow

This course demonstrates the four profiling Agent Skills as one evidence-driven lifecycle. Finish each phase before moving to the next so that code changes remain traceable to measured evidence.

1. 161-java-profiling-detect

Purpose: Data collection and problem identification
Example request: Set up problem-driven profiling for this Java application with the 161-java-profiling-detect skill and store the artifacts under profiler/.

2. 162-java-profiling-analyze

Purpose: Systematic analysis, evidence documentation, and solution prioritization
Example request: Analyze the artifacts under profiler/results with the 162-java-profiling-analyze skill and document evidence, assumptions, and prioritized solutions.

3. 163-java-profiling-refactor

Purpose: Targeted refactoring based on trusted profiling analysis
Example request: Apply the approved profiling solutions with the 163-java-profiling-refactor skill and verify the project test suite.

4. 164-java-profiling-verify

Purpose: Before/after validation, regression detection, and improvement measurement
Example request: Compare the baseline and post-refactoring artifacts with the 164-java-profiling-verify skill under identical load conditions.


🎯 Key Concepts Covered

Memory Leak Patterns

  • βœ… Unbounded collection growth
  • βœ… Thread pool resource leaks
  • βœ… Missing lifecycle management
  • βœ… Cache leaks and retention issues

Profiling Techniques

  • βœ… async-profiler mastery (21 profiling options)
  • βœ… JFR analysis and interpretation
  • βœ… Flamegraph visual analysis
  • βœ… Load testing integration with JMeter

Enterprise Patterns

  • βœ… Bounded collections with graceful degradation
  • βœ… Shared resource management
  • βœ… @PreDestroy lifecycle patterns
  • βœ… Monitoring and alerting infrastructure

Analysis Methodologies

  • βœ… Problem-driven profiling strategies
  • βœ… Impact/Effort prioritization frameworks
  • βœ… Cross-correlation analysis techniques
  • βœ… Evidence-based documentation

πŸ” Interactive Elements Throughout the Course

🧠 Knowledge Checks

  • "Before we continue, can you explain why GC retention grows with active memory leaks?"
  • "What would happen if we didn't implement @PreDestroy in our thread pools?"
  • "How do you interpret a flamegraph where the canvas height keeps growing?"

πŸ’‘ Learning Reinforcement

  • "Notice how the NoCocoController eliminates the memory leak - that's the power of proper resource lifecycle management!"
  • "This connects to our earlier lesson on bounded collections - remember the MAX_OBJECTS pattern?"
  • "The 318% memory retention increase we observed demonstrates why systematic profiling is critical!"

🎯 Practical Challenges

  • Implement custom bounded collections with error handling
  • Design monitoring strategies for production memory leak detection
  • Create custom profiling configurations for specific scenarios
  • Develop team knowledge transfer materials

πŸ“Š Success Metrics and Validation

Technical Success Criteria

  • [ ] Memory leaks successfully detected and resolved
  • [ ] Quantified performance improvements documented
  • [ ] Systematic profiling workflow mastered
  • [ ] Production-ready monitoring strategy developed

Learning Validation Methods

  • [ ] Hands-on exercises completed successfully
  • [ ] Profiling reports generated and analyzed
  • [ ] Documentation created following professional templates
  • [ ] Knowledge check questions answered correctly

Real-World Application

  • [ ] Techniques applied to actual production applications
  • [ ] Team knowledge sharing sessions conducted
  • [ ] Performance monitoring integrated into CI/CD pipeline
  • [ ] Continuous improvement processes established

πŸŽ“ Course Philosophy

Progressive Learning Design

This course follows a progressive learning approach:
- Extract core concepts from the four profiling Agent Skills
- Structure content into progressive learning modules
- Create interactive exercises with guided solutions
- Generate comprehensive courses with multiple paths
- Provide assessments and validation checkpoints


"The best time to learn performance optimization was yesterday. The second best time is now."

Happy profiling! Go to the foundations πŸš€