Understand the Java memory model and space recovery


I tend to get these questions asked by a lot by students, or by co-workers looking for a resource, so I wanted a more definite reference for them. Might as well share it with the community.

  • How is the Java Memory Model represented and what are its characteristics?

  • How does Garbage Collection work in general and in the most common JVMs?

  • How do I test and tune my Java applications for performance?

Memory Basics

  • What Every Programmer Should Know About Memory - Ulrich Drepper [PDF]

Java Language and Virtual Machine Specifications

  • The Java Virtual Machine Specification [PDF and HTML for Java SE 7]

Java Memory Model

  • Advanced Topics in Programming: The Java Memory Model - Jeremy Manson [video]
  • Collection of Resources on the Java Memory Model - edited and compiled by Bill Pugh (collection)
  • Memory Management in the HotSpot Virtual Machine - Sun Microsystems (2006) [PDF]
  • Fixing the Java Memory Model - Brian Goetz, IBM Java Developer Series () [part 1, part 2]

Java Performance

  • 9 Fallacies of Java Performance - Ben Evans [video + slides]
  • JVM Performance Magic Tricks - Takipi [blog + slides]
  • Java and the Machine - Kirk Pepperdine, Martijn Verburg [video + slides]
  • Performance Testing Java Applications - Martin Thompson [video + slides]
  • Building Memory-Efficient Java Applications: Practices and Challenges - Mitchell, Sevitsky (2009) [PDF]

Advanced Topics and Real-Life Uses Cases

  • Optimizing Google’s Warehouse Scale Computers: The NUMA Experience - University of California & Google [PDF]
  • MegaPipe: A New Programming Interface for Scalable Network I/O [Google Doc]
  • Mythbusting modern hardware to gain "Mechanical Sympathy" - Martin Thompson [PDF] (slides)
  • Caching in: understand, measure and use your CPU Cache more effectively - Richard Warburton [video + slides]
  • A JVM Does That?! - Cliff Click [video]

GC Tuning

  • Hotspot Garbage Collection - Tuning Guide - Martijn Verburg, John Oliver [video, slides pt 1, slides pt 2]
  • Are your GC logs speaking to you, the G1GC edition [slides, video]
  • The Principles of Java Application Performance Tuning [article]
  • Everything I Ever Learned About JVM Performance Tuning @Twitter - Attila Szegedi [video & slides]
  • Visualizing Java GC - Ben Evans [video + slides]

Complementary StackExchange Questions and Answers

  • Java Memory Model
  • JRockit JVM versus HotSpot JVM
  • How to destroy java objects?
  • Smart Garbage Collection?

And many, many more to come that I need to dig up from my archives or from the inter-tubes.