黑马程序员技术交流社区

标题: 求大神解释一下数据结构,自己总结了一部分,求补充和改正 [打印本页]

作者: itheima01    时间: 2013-4-14 18:58
标题: 求大神解释一下数据结构,自己总结了一部分,求补充和改正
栈内存,堆内存,常量区,方法区,静态区,线程池,共享数据区的关系。自己总结了一点,但是不太全面,求补充。  栈内存:存放数据变量,数据引用变量,用完直接释放,堆内存:存放实例对象,当没有引用成为垃圾的时候就会被垃圾回收机制不定时回收。常量区,放的是常量。方法区有点迷惑,放的是字符串,静态区,代码区。线程池放的是线程。其他都不知道了 。
作者: 杜鹏飞    时间: 2013-4-14 20:18
别自己yy了,看看java virtual machine specification,javase7edition吧

作者: 杜鹏飞    时间: 2013-4-14 20:27
为了防止你继续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.
作者: 杜鹏飞    时间: 2013-4-14 20:31
现在同时考虑win32api和汇编语言.
jvm栈相当于.stack,frame相当于独立于方法的stack,动态分配内存都是从堆里取的(winos32apiheapalloc),
method area就是.code,run-time constant pool相当于.data
作者: mvplee    时间: 2013-4-14 20:42
太没营养了!
作者: 刘胜寒    时间: 2013-4-14 21:00
你能解释一下什么是数据结构吗??
你说的我怎么没看到数据结构的影子啊...

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

非常感谢,就你帮助了俺。
作者: 高新星    时间: 2013-4-16 08:23
itheima01 发表于 2013-4-15 22:02
非常感谢,就你帮助了俺。

呵呵!!!我也遇到过同样的问题
作者: 645420297    时间: 2013-4-16 10:03
1楼大神...




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2