【问题标题】:storage of static instance variables [duplicate]静态实例变量的存储[重复]
【发布时间】:2012-10-24 00:18:47
【问题描述】:

可能重复:
What is the actual memory place for static variables?

类中定义的静态实例变量存储在哪里——堆还是永久代?

JLS(pre java SE 7 和 Java SE 7)说:

17.4.1   Shared Variables
Memory that can be shared between threads is called shared memory or heap
memory.
All instance fields, static fields and array elements are stored in heap memory.

但是this 帖子说:

Success Metrics
...
Class metadata, interned Strings and class static variables will be moved from the permanent generation to either the Java heap or native memory.
...

Description
...
Class metadata and statics are allocated in the permanent generation when a class is loaded and are garbage collected from the permanent generation when the class is unloaded. Interned Strings are also garbage collected when the permanent generation is GC’ed.
...

根据上面的帖子静态是在永久代区域。

哪个是正确的??

【问题讨论】:

    标签: java


    【解决方案1】:

    在文章中

    Java 堆的一部分称为永久代

    所以永久代在堆中。

    【讨论】:

      猜你喜欢
      • 2016-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-28
      • 2014-02-03
      • 1970-01-01
      • 2015-11-03
      • 2014-02-07
      相关资源
      最近更新 更多