Java: JVM & Memory
Read the machine under your program
Java hands you a machine you never see. A collector decides when your objects die. A second thread may not have noticed your last write, and is entitled not to. A map loses a key it is visibly holding. This project is that machine, read from the outside and then proved in one program you compile and run yourself.
- Modules
- 6
- Drills
- 9
- Build steps
- 9
- Time
- ~5h
Walk out able to
Read unfamiliar Java and say what the runtime is entitled to do with it — what dies, what is holding the rest, and what a second thread is guaranteed to see.
What you work on
Frames, heaps and classes
Where a value lives, and when its class wakes up.
What the collector keeps
Reachability from roots, and what is holding the rest.
Soft, weak and phantom
The strength a requirement needs, chosen not guessed.
Visibility and hash keys
What crosses threads, and what a map quietly loses.
The pitch
What you practise, and what you leave with
A Java file you compile and run that diagnoses its own cache: lost keys, a weak map that never empties, and two thread totals.
You will practise
- Where a value lives, when a class wakes
- Reachability, cycles, and what retains
- Soft, weak and phantom, from a need
- Happens-before, and the hash contract
Afterwards you can
- Count what the collector may take, from code
- Name the root path keeping an object alive
- Say whether a write is guaranteed visible
- Tell a safe hash key from one that is lost
Modules
6 modules, 38 items
Lessons explain one idea. Drills repeat it until it sticks. Build steps make something that exists afterwards.
- 1
After javac, before main
~58 minSay where any value lives, and which classes a program wakes up before it prints.
- LessonWhat you are looking at5 min
- LessonTwo jumps, not one6 min
- LessonWhere a value lives7 min
- LessonWhen a class wakes up6 min
- DrillSay where the value lives10 min
- DrillSay which class wakes up12 min
- Build stepCompile it and look inside12 min
- 2
What the collector keeps
~59 minCount what is unreachable, and name the root path keeping the rest alive.
- LessonWhy a cycle still dies6 min
- LessonTrace from the roots instead6 min
- LessonMost objects die young7 min
- LessonWhat a leak is here5 min
- DrillCount what the collector can take12 min
- DrillName what is holding it13 min
- Build stepWatch a heap fill and drain10 min
- 3
Choose the reference strength
~41 minOrder the four strengths, and pick the one a stated requirement actually needs.
- LessonWho decides when this dies6 min
- LessonAs strong as its strongest path6 min
- LessonBeing told instead of asking6 min
- DrillPick the strength it needs13 min
- Build stepAsk the three references10 min
- 4
What another thread can see
~53 minName the edge that guarantees a write is visible — or say that there is not one.
- LessonThe loop that does not stop5 min
- LessonThe list of edges7 min
- LessonWhat a volatile write carries6 min
- LessonVisible and still wrong5 min
- LessonThe one free guarantee5 min
- DrillName the edge that guarantees it13 min
- Build stepCount it twice12 min
- 5
Keep the hash contract
~49 minName the clause a class breaks, and predict what a map does when a key changes.
- LessonA map does not search6 min
- LessonThe six clauses7 min
- LessonCheck the number yourself6 min
- LessonThe repair is upstream5 min
- DrillName the clause it breaks12 min
- DrillSay what the map prints13 min
- 6
Run the cache clinic
~1hGet the runtime lines back from memory, then build a cache that fails four ways.
- DrillWrite the runtime lines10 min
- Build stepWrite the key the cache uses12 min
- Build stepFill it from a fixed draw12 min
- Build stepBreak it with one assignment12 min
- Build stepLet the cache forget12 min
- Build stepRun the whole clinic8 min
More in Languages
Keep going
Python Foundations
Read a program before you run it. Then write one worth showing.
Foundational~6h8 modules
Python Fluency
Choose the shape before you type. Then say it in one line.
Intermediate~5h7 modules
Python Confidence
Somebody else wrote it. Find out whether it works.
Advanced~7h7 modules
Python Craft
It works. Now make it somebody else's.
Advanced~10h7 modules
Your objects die on a schedule nobody showed you.
The first item is free. ~5h of focused work, at your own pace.
Advanced~5h6 modules