References Role in Garbage Collection

  1. Strong References
  2. Weak References
  3. Soft References
  4. Phantom References
  • This type of reference is used in WeakHashMap to reference the entry objects.
  • If JVM detects an object with only weak references (i.e. no strong or soft references linked to any object), this object will be marked for garbage collection.
  • To create such references java.lang.ref.WeakReference class is used.
  • These references are used in real-time applications while establishing a DBConnection which might be cleaned up by Garbage Collector when the application using the database gets closed.

--

--

--

Senior Android App Developer | Startup | Product base | Java | Kotlin | MVVM | Architecture components | Android Blogger

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

There Is No Perfect Lifecycle For Your Project

Even today, developing a successful Web3 application isn’t easy.

What is the biggest non-technical lesson I have learned in my journey as a developer?

The value of good communication in work place

CS373 Fall 2020: Jordan Wang

How to Hire a Magento Maintenance Partner?

Hire a Magento Maintenance Partner

Introduction to NoSQL (with Pros & Cons)

DevOps should empower Developers!

DevOps should empower Developers! | @iSwamiK

Using Kafka topic to implement near cache or cache sync between micros-services

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aalishan Ansari

Aalishan Ansari

Senior Android App Developer | Startup | Product base | Java | Kotlin | MVVM | Architecture components | Android Blogger

More from Medium

Java Character Streams: BufferedReader, InputStreamReader etc.

Java, JVM, JRE and JDK

Optimizing GC time by reducing Humongous allocations

Java Multithreading, Concurrency, and Parallelism — Part 17.2