Whats up with static memory in java?

前端 未结 6 492
情深已故
情深已故 2020-12-02 19:17

This question is for the java language in particular. I understand that there is a static protion of memory set aside for all static code.

My question is how is this

6条回答
  •  無奈伤痛
    2020-12-02 20:09

    If the static field is changed to reference a different object, the original object pointed to by the static field is eligible for GC just like any other object.

    It could also be free'ed (even if not nulled) if the class itself is unloaded and the entire object graph is cut from the heap. Of course, when a class can be unloaded is a good topic for a host of other questions... :)

提交回复
热议问题