{
  "id": 19150509,
  "title": "How Java Garbage Collection Works: A Quick Walkthrough",
  "url": "https://urgent.news/2026/11/09/how-java-garbage-collection-works-a-quick-walkthrough",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-09T12:30:16.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/vishnub33527201/how-java-garbage-collection-works-a-quick-walkthrough-3fa7"
  },
  "original_language": "en",
  "account": "Java has no free() and no delete . When you stop referencing an object, its memory is quietly reclaimed by the garbage collector. The rule it follows is called reachability. The garbage collector starts from a fixed set of entry points, such as local variables on every live thread's stack, static fields, and a few JVM internals. From there, it walks the object graph to determine which objects are reachable. Anything reachable stays in memory, while everything else is considered garbage. This animation represents the classic mark-and-sweep concept, though real collectors add generations, regions, threads, and concurrency to optimize the process. In the provided example, a Java program allocates 20 objects of approximately 100 KB each per round, totaling around 600 MB of garbage. The program also creates a single object behind a WeakReference to watch it die. The output shows that the garbage collector reclaimed 600 MB of objects across 69 young collections in a small sandbox VM using the Serial collector. It's important to note that reclaiming objects doesn't necessarily return memory to the operating system; the JVM retains that memory for future allocations. The garbage collector itself is ordinary JVM code running in user space, performing memory operations without requiring system calls.",
  "summary": "Java has no free() and no delete . You stop referencing an object, and at some point its memory quietly comes back. Someone is doing that work: the garbage collector. Let's pin down the rule it uses, watch a real JVM collect live, and then be honest about where the JVM ends and the operating system begins. The one rule: reachability The collector does not count references or guess. It starts from…",
  "key_points": [
    "Java has no free() or delete for manual memory management",
    "Garbage collector identifies reachable objects from entry points",
    "Reclaimed 600 MB of objects across 69 young collections"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}