A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

栈内存,堆内存,常量区,方法区,静态区,线程池,共享数据区的关系。自己总结了一点,但是不太全面,求补充。  栈内存:存放数据变量,数据引用变量,用完直接释放,堆内存:存放实例对象,当没有引用成为垃圾的时候就会被垃圾回收机制不定时回收。常量区,放的是常量。方法区有点迷惑,放的是字符串,静态区,代码区。线程池放的是线程。其他都不知道了 。

评分

参与人数 1技术分 +1 收起 理由
田磊阳 + 1

查看全部评分

11 个回复

倒序浏览
别自己yy了,看看java virtual machine specification,javase7edition吧
回复 使用道具 举报
为了防止你继续yy+说一些并不存在的"术语",也为了防止你说我是yy的,所以我帮你在语言标准里摘了一大段废话

Java Virtual Machine Stacks
Each Java Virtual Machine thread has a private Java Virtual Machine stack, created
at the same time as the thread. A Java Virtual Machine stack stores frames (§2.6).
A Java Virtual Machine stack is analogous to the stack of a conventional language
such as C: it holds local variables and partial results, and plays a part in method
invocation and return. Because the Java Virtual Machine stack is never manipulated
directly except to push and pop frames, frames may be heap allocated. The memory
for a Java Virtual Machine stack does not need to be contiguous.

Fram
A frame is used to store data and partial results, as well as to perform dynamic
linking, return values for methods, and dispatch exceptions.
A new frame is created each time a method is invoked. A frame is destroyed when
its method invocation completes, whether that completion is normal or abrupt (it
throws an uncaught exception). Frames are allocated from the Java Virtual Machine
stack (§2.5.2) of the thread creating the frame. Each frame has its own array of
local variables (§2.6.1), its own operand stack (§2.6.2), and a reference to the run-
time constant pool (§2.5.5) of the class of the current method.

Heap
The Java Virtual Machine has a heap that is shared among all Java Virtual Machine
threads. The heap is the run-time data area from which memory for all class
instances and arrays is allocated.

Method Area
The Java Virtual Machine has a method area that is shared among all Java Virtual
Machine threads. The method area is analogous to the storage area for compiled
code of a conventional language or analogous to the "text" segment in an operating
system process. It stores per-class structures such as the run-time constant pool,
field and method data, and the code for methods and constructors, including
the special methods (§2.9) used in class and instance initialization and interface
initialization.

Run-Time Constant Pool
A run-time constant pool is a per-class or per-interface run-time representation
of the constant_pool table in a class file (§4.4). It contains several kinds of
constants, ranging from numeric literals known at compile-time to method and field
references that must be resolved at run-time. The run-time constant pool serves a
function similar to that of a symbol table for a conventional programming language,
although it contains a wider range of data than a typical symbol table.
回复 使用道具 举报
现在同时考虑win32api和汇编语言.
jvm栈相当于.stack,frame相当于独立于方法的stack,动态分配内存都是从堆里取的(winos32apiheapalloc),
method area就是.code,run-time constant pool相当于.data
回复 使用道具 举报
太没营养了!
回复 使用道具 举报
你能解释一下什么是数据结构吗??
你说的我怎么没看到数据结构的影子啊...
回复 使用道具 举报
可以看看这篇博客http://uule.iteye.com/blog/1417299

评分

参与人数 1技术分 +1 收起 理由
田磊阳 + 1

查看全部评分

回复 使用道具 举报
用不着搞那么清楚,现在。分清栈和堆就可以了,栈里放变量和引用,堆里放对象,至于更细节的,学完基础再研究去吧,也就是增加点理解,对前期编程没啥影响。
回复 使用道具 举报
黄玉昆 黑马帝 2013-4-15 12:08:37
9#
如果问题未解决,请继续追问,如果没有问题了,请将帖子分类 改为“已解决”,谢谢
回复 使用道具 举报
高新星 发表于 2013-4-14 21:21
可以看看这篇博客http://uule.iteye.com/blog/1417299

非常感谢,就你帮助了俺。

点评

请改为已解决  发表于 2013-4-15 23:33
回复 使用道具 举报
itheima01 发表于 2013-4-15 22:02
非常感谢,就你帮助了俺。

呵呵!!!我也遇到过同样的问题
回复 使用道具 举报
1楼大神...
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马