Whats up with static memory in java?

前端 未结 6 491
情深已故
情深已故 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 19:52

    There is normally no such thing as "static" memory. Most vm's have the permanent generation of the heap (where classes get loaded), which is normally not garbage collected.

    Static objects are allocated just like any other object. But, if they live for long they will be moved between the different generations in the garbage collector. But they will not end up in permgenspace.

    If your class is holding onto this object permanently, it will only be released when the vm exits.

提交回复
热议问题