由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - Java Object 一定在 Heap 里吗
相关主题
OutofMemoryError: Java Heap SpaceJDK8要出来了?
今天被老印grill了Tomcat Hot deployment
我来回答一下投行IT的问题使用Clob的setString方法出现如下错误
Oracle的jvm收费版本oracle/sun deal
java在美国到底怎样?what's inside an java object?
array 在java里 是一定放在heap 吗?Oracle收购Sun后 最新公布的产品策略,怀念SUN
请教frameworkJava's performance myth
Interview的人问我最新java 版本是多少xp 是不是不支持jave 阿?
相关话题的讨论汇总
话题: permgen话题: heap话题: java话题: object话题: hotspot
进入Java版参与讨论
1 (共1页)
F****n
发帖数: 3271
1
这是Java interview问烂的问题吧。
最近我发现这个问题可以翻出来再问问
不知道版上有多少人能答对:)
g*****g
发帖数: 34805
2
Yes.

【在 F****n 的大作中提到】
: 这是Java interview问烂的问题吧。
: 最近我发现这个问题可以翻出来再问问
: 不知道版上有多少人能答对:)

s******e
发帖数: 493
3
I doubt that a simple yes or no will be able to answer this question
correctly.
Java objects basically can be divided into class object and instance object.
All instance objects are saved in the heap. Even for a static member of a
class. In such a case, only the class variable will be in permgen. But all
class objects will be in permgen.
If my memory is correct, JMM spec mentions four types of memory space: stack
, heap, permgen and code cache.
z*******3
发帖数: 13709
4
如果我没有记错
static变量是放在方法区里面
跟类本身的生命周期共进退
不完全是heap区
z*******3
发帖数: 13709
5
这个我狗了一下哈
发现permgen只有hotspot有实现
其它的jvm都没有实现,而且在逐步淘汰permgen
那方法区理论上已经算是heap的一部分来实现了
那笼统地可以认为都在heap里面
规范里叫做方法区的抽象区域,与“永久代”并不等价。只是在现在的Oracle (Sun)
HotSpot使用“永久代”来实现方法区而已。
服务器端主流的高性能JVM现在就三种,一个是HotSpot(其中Sun的原始版本用得最多
,由其衍生出来的Azul版与HP版也颇有应用;Apple的Mac OS上的JVM也是从Sun的版本
衍生出来的,不过拿Mac来做服务器的大概不多吧);一个是Oracle (BEA)的JRockit;
还有一个是IBM的JVM,现在主要在用的是J9。这之中,只有HotSpot是有PermGen的,而
JRockit与J9都没有;连Azul版HotSpot也经过改进早已去除了PermGen。概念上说这些
JVM都有符合规范的“方法区”,但并不一定要用PermGen来实现就是了。
甚至连Oracle (Sun)的HotSpot也实质性开始去除PermGen的工作了。请参考最近的
hotspot-dev邮件列表里的一封邮件:Request for review (XL) 6990754: Use native
memory and reference counting to implement SymbolTable
等JDK 7正式发布的时候,里面的HotSpot多半就已经没有PermGen了。

object.
stack

【在 s******e 的大作中提到】
: I doubt that a simple yes or no will be able to answer this question
: correctly.
: Java objects basically can be divided into class object and instance object.
: All instance objects are saved in the heap. Even for a static member of a
: class. In such a case, only the class variable will be in permgen. But all
: class objects will be in permgen.
: If my memory is correct, JMM spec mentions four types of memory space: stack
: , heap, permgen and code cache.

z*******3
发帖数: 13709
6
这里面有几个小疑点
一个是方法区的实现是否在heap里面实现
还是额外滴在heap以外的地方实现
如果是在PermGen里面实现的话
就要看看static变量的主体是否在这个区里面
不过如果smectite说得是对的话
static变量其实只存引用在permgen里面
然后主体还是在heap里面
是不是这样理解?
这个是虚拟机的问题
f*******n
发帖数: 12623
7
And what the hell is a "class object"?

object.
stack

【在 s******e 的大作中提到】
: I doubt that a simple yes or no will be able to answer this question
: correctly.
: Java objects basically can be divided into class object and instance object.
: All instance objects are saved in the heap. Even for a static member of a
: class. In such a case, only the class variable will be in permgen. But all
: class objects will be in permgen.
: If my memory is correct, JMM spec mentions four types of memory space: stack
: , heap, permgen and code cache.

F****n
发帖数: 3271
8
Java 7 escape analysis
Objects only referenced by local variables are stored in stack instead of
heap.
z*******3
发帖数: 13709
9
The JDK 8 HotSpot JVM is now using native memory for the representation of
class metadata and is called Metaspace; similar to the Oracle JRockit and
IBM JVM's.
* UPDATE: PermGen space is official removed in Java 8 and replaced by
Metaspace.
z*******3
发帖数: 13709
10
PermGen从java8开始走入历史了
1 (共1页)
进入Java版参与讨论
相关主题
xp 是不是不支持jave 阿?java在美国到底怎样?
Stupid IBM JDKarray 在java里 是一定放在heap 吗?
JDK Source?请教framework
Stupid IBM JVM: operator precedenceInterview的人问我最新java 版本是多少
OutofMemoryError: Java Heap SpaceJDK8要出来了?
今天被老印grill了Tomcat Hot deployment
我来回答一下投行IT的问题使用Clob的setString方法出现如下错误
Oracle的jvm收费版本oracle/sun deal
相关话题的讨论汇总
话题: permgen话题: heap话题: java话题: object话题: hotspot