I know that a retain cycle (at least in Objective-C and Swift) is when two objects claim ownership of one another (they have references to each other). And in Objective-C we can
As the name suggests, Garbage Collection refers to removing of objects which are no longer in use. It is a well known fact that irrespective of their scope objects, Java stores objects in heap. Thus, if we keep on creating objects without clearing the heap, our computers might run out of heap space and we get ‘Out of Memory’ error. Garbage Collection in Java is a mechanism which is controlled and executed by the Java Virtual Machine (JVM) to release the heap space occupied by the objects which are no more in use. In contrast to C++, garbage collection in java relives the developer from the Memory Management related activities. The JVM executes this process with the help of a demon thread called the ‘Garbage Collector’. The garbage collector thread first invokes the finalize method of the object. This performs the cleanup activity on the said object. As a developer we cannot force the JVM to run the garbage collector thread. Though there are methods e.g Runtime.gc () or System.gc(), but none of these assures the execution of garbage collector thread. These methods are used to send garbage collection requests to the JVM. It is up to the Java Virtual machine when it will initiate the garbage collection process.
Take a look at this stuff
How Garbage Collection works in Java