Created
November 17, 2021 11:40
-
-
Save Bringoff/7401b06198a148757cf80a3c0fa89aff to your computer and use it in GitHub Desktop.
Circular references
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main(args: Array<String>) { | |
| Inner().nodes() | |
| readLine() | |
| System.gc() | |
| readLine() | |
| } | |
| class Inner { | |
| fun nodes() { | |
| val first = Node() | |
| val second = Node() | |
| first.child = second | |
| second.child = first | |
| } | |
| } | |
| class Node { | |
| var child: Node? = null | |
| protected fun finalize() { | |
| println("${hashCode()} finalized") | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment