Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Garbage collection java

how does the garbage collector in java determine that objects are no longer referenced by the program?

like image 923
jaffa Avatar asked Jun 24 '26 20:06

jaffa


2 Answers

It depends on the VM but there are a number of ways it could be done.

like image 188
Chris Thompson Avatar answered Jun 26 '26 09:06

Chris Thompson


Check this out.

  1. Easy way to explain how GC works...
  2. How GC works ?

Reference :

Fig : General Collection of Object

General Collection


Fig : Memory Collection of Objects

Memory Collection

like image 26
Saurabh Gokhale Avatar answered Jun 26 '26 08:06

Saurabh Gokhale



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!