Like a static variable processed by gc

How is a static variable handled by the garbage collector and where do they allocate memory? on the heap or the stack (as member variables) Please clarify this for me.

+3
source share
1 answer

Static variables are only suitable for garbage collection, when the class itself is garbage collection, and classes are only suitable for garbage collection if the class loader loading them collects garbage.

See JLS § 12.7 :

, , . 12.6. , , .

.

+7

Source: https://habr.com/ru/post/1748342/


All Articles