---
title: "Discussion on \"06 Java - Memory Management and Garbage Collector\" | Hashnode"
description: "Discussion on \"06 Java - Memory Management and Garbage Collector\". Types of Memory\nThere are 2 types of Memory\n\nSTACK\n\nHEAP\n\n\nBoth stack and Heap are created by JVM and stored in RAM.\n\nStack Memory\n\nStore Temporary variables and separate memory block for methods.\n\nStore Primitive data types\n\nStore Reference of the h..."
url: "https://hashnode.com/posts/06-java-memory-management-and-garbage-collector/6619025b7e2645a9e7554e1f"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [06 Java - Memory Management and Garbage Collector](https://chetan77.hashnode.dev/06-java-memory-management-and-garbage-collector?utm_source=hashnode&utm_medium=feed)

Types of Memory There are 2 types of Memory STACK HEAP Both stack and Heap are created by JVM and stored in RAM. Stack Memory Store Temporary variables and separate memory block for methods. Store Primitive data types Store Reference of the h...

Apr 12, 2024 · 6 min read · chetan77.hashnode.dev  
Updated Jul 6, 2025  
Read the article

-   [#memory-management](https://hashnode.com/tag/memory-management)
-   [#java](https://hashnode.com/tag/java)
-   [#software-development](https://hashnode.com/tag/software-development)
-   [#garbage-collector](https://hashnode.com/tag/garbage-collector)

## Written by

[Chetan Datta](https://hashnode.com/@chetan77)

@chetan77 · Hyderabad, India

  
[View profile](https://hashnode.com/@chetan77)

Software Engineer

I share my learnings here. Thanks for reading.

## Responses 2

Markdown supported · ⌘↵ to post

[Sukhvir Kaur](https://hashnode.com/@sukhdhanota)

[Jun 24, 2025](https://hashnode.com/posts/06-java-memory-management-and-garbage-collector/6619025b7e2645a9e7554e1f/comment/685acb7133c25fffd5e45439)

❓ "Soft Reference is a type of Weak Reference" — is this correct?

❌ Technically Incorrect While both SoftReference and WeakReference are part of the same reference family (i.e., they are subclasses of java.lang.ref.Reference), SoftReference is not a subtype of WeakReference.

✅ Correct Statement: "SoftReference and WeakReference are two different types of non-strong references. Both extend the abstract class Reference, but neither is a subtype of the other."

[Chetan Datta](https://hashnode.com/@chetan77)

[Jul 6, 2025](https://hashnode.com/posts/06-java-memory-management-and-garbage-collector/6619025b7e2645a9e7554e1f/comment/685acb7133c25fffd5e45439#reply-686a77b6cd4c4d79d93bcaeb)

[Sukhvir Kaur](https://hashnode.com/@sukhdhanota) Thanks for catching that! I’ve updated it.

[Shubham Kesri](https://hashnode.com/@kesri)

[Oct 21, 2024](https://hashnode.com/posts/06-java-memory-management-and-garbage-collector/6619025b7e2645a9e7554e1f/comment/6715fe86956a891637ec4818)

In Mark and Sweep, the referenced objects are marked and unreferenced objects are swept from heap.

**Working of Grabage Collector** say otherwise.

[Chetan Datta](https://hashnode.com/@chetan77)

[Nov 2, 2024](https://hashnode.com/posts/06-java-memory-management-and-garbage-collector/6619025b7e2645a9e7554e1f/comment/6715fe86956a891637ec4818#reply-6725cd4262b4b21d3db24f61)

Hi [Shubham Kesri](https://hashnode.com/@kesri),

Noted! I'll make the necessary changes and link the references you've quoted here.

Thank you for sharing the resources.

[Shubham Kesri](https://hashnode.com/@kesri)

[Feb 26, 2025](https://hashnode.com/posts/06-java-memory-management-and-garbage-collector/6619025b7e2645a9e7554e1f/comment/6715fe86956a891637ec4818#reply-67bf1e2d6e2d865791d06582)

Hi [Chetan Datta](https://hashnode.com/@chetan77), any updates ?

[Chetan Datta](https://hashnode.com/@chetan77)

[Mar 16, 2025](https://hashnode.com/posts/06-java-memory-management-and-garbage-collector/6619025b7e2645a9e7554e1f/comment/6715fe86956a891637ec4818#reply-67d64369c426b810f91bc07d)

Updated [Shubham Kesri](https://hashnode.com/@kesri)
