kunal-kushwaha / DSA-Bootcamp-Java

This repository consists of the code samples, assignments, and notes for the Java data structures & algorithms + interview preparation bootcamp of WeMakeDevs.
https://www.youtube.com/playlist?list=PL9gnSGHSqcnr_DxHsP7AW9ftq0AtAyYqJ
16.31k stars 10.59k forks source link

Used System.gc() to simplify the process of hitting garbage collection in finalize() method example #1172

Open abhisheks-gh opened 10 months ago

abhisheks-gh commented 10 months ago

At line 33, when we are checking for how many times the object is getting destroyed by garbage collector using the finalize() method, adding System.gc() will recommend the garbage collector to run even for a comparatively small number of unreferenced objects of class A.