- 浏览: 1147279 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (411)
- Java Foundation (41)
- AI/机器学习/数据挖掘/模式识别/自然语言处理/信息检索 (2)
- 云计算/NoSQL/数据分析 (11)
- Linux (13)
- Open Source (12)
- J2EE (52)
- Data Structures (4)
- other (10)
- Dev Error (41)
- Ajax/JS/JSP/HTML5 (47)
- Oracle (68)
- FLEX (19)
- Tools (19)
- 设计模式 (4)
- Database (12)
- SQL Server (9)
- 例子程序 (4)
- mysql (2)
- Web Services (4)
- 面试 (8)
- 嵌入式/移动开发 (18)
- 软件工程/UML (15)
- C/C++ (7)
- 架构Architecture/分布式Distributed (1)
最新评论
-
a535114641:
LZ你好, 用了这个方法后子页面里的JS方法就全不能用了呀
页面局部刷新的两种方式:form+iframe 和 ajax -
di1984HIT:
学习了,真不错,做个记号啊
Machine Learning -
赵师傅临死前:
我一台老机器,myeclipse9 + FB3.5 可以正常使 ...
myeclipse 10 安装 flash builder 4.6 -
Wu_Jiang:
触发时间在将来的某个时间 但是第一次触发的时间超出了失效时间, ...
Based on configured schedule, the given trigger will never fire. -
cylove007:
找了好久,顶你
Editable Select 可编辑select
未完 JVM Runtime Data Areas & Java Memory Model | 内存分配模型 & Java数据存储
- 博客分类:
- Java Foundation
Java虚拟机内存分配模型
需精读:Chapter 5 of Inside the Java Virtual Machine - The Java Virtual Machine:
http://www.artima.com/insidejvm/ed2/jvm2.html
http://blog.jamesdbloom.com/JVMInternals.html
Java Virtual Machine Specification - Runtime Data Areas:
http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-2.html#jvms-2.5
http://blog.csdn.net/silentbalanceyh/article/details/4661230
Java Memory Model:
jls 17.4 - Memory Model:
http://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.4
The Java Memory Model:
http://www.cs.umd.edu/~pugh/java/memoryModel/index.html#reference
JSR-133: Java Memory Model and Thread Specification:
https://www.cs.umd.edu/users/pugh/java/memoryModel/jsr133.pdf
关于java的内存分配,网上有种提法说分heap/stack/data segment/code segment。如下:
http://wenku.baidu.com/view/efa5a3d9a58da0116c174988.html
不知道这是谁发明的,不过这种提法是不正确的。stack和heap java中是有没错,但data segment 和 code segment,是C语言内存分配中的概念,也是大学组成原理课里的概念,在java世界里,没这种说法!
参考:http://www.coderanch.com/t/392047/java/java/Code-Data-segment
需精读:Chapter 5 of Inside the Java Virtual Machine - The Java Virtual Machine:
http://www.artima.com/insidejvm/ed2/jvm2.html
引用
所有的对象都是分配在heap上的
http://blog.jamesdbloom.com/JVMInternals.html
引用
Java Virtual Machine Specification - Runtime Data Areas:
http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-2.html#jvms-2.5
引用
The pc Register
Each Java virtual machine thread has its own pc (program counter) register.
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.
每个线程有各自独立的Stack实例,存放:局部变量 / 方法参数 / 中间计算结果
Heap
The Java virtual machine has a heap that is shared among all Java virtual machine threads. The heap is the runtime data area from which memory for all class instances and arrays is allocated.
jvm中只有一个Heap实例,存放:实例变量 / 所有的对象 ....and ..?
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 runtime 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.
jvm中只有一个Method Area实例,存放:类变量 / information about loaded types(class,interface,etc)...and ..?
Runtime Constant Pool
A runtime constant pool is a per-class or per-interface runtime 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 runtime. The runtime 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.
Constant pool 位于 Method Area 中。
Native Method Stacks
Java内存模型:
Each Java virtual machine thread has its own pc (program counter) register.
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.
每个线程有各自独立的Stack实例,存放:局部变量 / 方法参数 / 中间计算结果
Heap
The Java virtual machine has a heap that is shared among all Java virtual machine threads. The heap is the runtime data area from which memory for all class instances and arrays is allocated.
jvm中只有一个Heap实例,存放:实例变量 / 所有的对象 ....and ..?
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 runtime 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.
jvm中只有一个Method Area实例,存放:类变量 / information about loaded types(class,interface,etc)...and ..?
Runtime Constant Pool
A runtime constant pool is a per-class or per-interface runtime 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 runtime. The runtime 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.
Constant pool 位于 Method Area 中。
Native Method Stacks
http://blog.csdn.net/silentbalanceyh/article/details/4661230
Java Memory Model:
jls 17.4 - Memory Model:
http://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.4
The Java Memory Model:
http://www.cs.umd.edu/~pugh/java/memoryModel/index.html#reference
JSR-133: Java Memory Model and Thread Specification:
https://www.cs.umd.edu/users/pugh/java/memoryModel/jsr133.pdf
关于java的内存分配,网上有种提法说分heap/stack/data segment/code segment。如下:
http://wenku.baidu.com/view/efa5a3d9a58da0116c174988.html
不知道这是谁发明的,不过这种提法是不正确的。stack和heap java中是有没错,但data segment 和 code segment,是C语言内存分配中的概念,也是大学组成原理课里的概念,在java世界里,没这种说法!
参考:http://www.coderanch.com/t/392047/java/java/Code-Data-segment
引用
Q:
Can anyone help me knowing what role exactly code segment and data segment plays in general in Java?
A:
I am not exactly sure what you mean by "code segment" etc.
When a class is used in any manner, it is automatically "loaded" the first time by the JVM. This causes a Classfile to be created for it, all the code is loaded into the Method Area, and any static initializers are executed.
Methods, constructors and initializing code (both static and non-static) are kept in the Method Area of the Classfile. There is no "per instance" implementation of code. The classfile and it's methods stay until the class is unloaded. Most of the classes that you will use as a beginner are loaded by the bootstrap classloader and stay put until the JVM comes down.
Data that is related to a particular object of the class (fields) are kept in the object itself on the heap. So each object has a field that relates to each variable that defines it's current state. If it inherits variable from a Super class, the object has a place for that also (even if it is hidden by a variable with the same name in the subclass).
Static variables are kept in a central location related to the Classfile. These variables are "shared" by all instances of the class. Of course those variables may hold references to objects which are themselves on the heap.
Can anyone help me knowing what role exactly code segment and data segment plays in general in Java?
A:
I am not exactly sure what you mean by "code segment" etc.
When a class is used in any manner, it is automatically "loaded" the first time by the JVM. This causes a Classfile to be created for it, all the code is loaded into the Method Area, and any static initializers are executed.
Methods, constructors and initializing code (both static and non-static) are kept in the Method Area of the Classfile. There is no "per instance" implementation of code. The classfile and it's methods stay until the class is unloaded. Most of the classes that you will use as a beginner are loaded by the bootstrap classloader and stay put until the JVM comes down.
Data that is related to a particular object of the class (fields) are kept in the object itself on the heap. So each object has a field that relates to each variable that defines it's current state. If it inherits variable from a Super class, the object has a place for that also (even if it is hidden by a variable with the same name in the subclass).
Static variables are kept in a central location related to the Classfile. These variables are "shared" by all instances of the class. Of course those variables may hold references to objects which are themselves on the heap.
发表评论
-
J2SE Evolution
2013-04-11 15:39 1185Java 7 New Features Java SE 7 ... -
未完 Java: IO & NIO(new I/O)
2013-01-11 20:56 2051适用: event and data-driven apps ... -
未完 java设计: naming convention | 命名规范
2012-11-20 16:45 2129应该遵循的规范: 类/接口/属性名,使用名词或形容词 ... -
未完 Java: enum 枚举
2012-11-19 20:29 1815http://stackoverflow.com/que ... -
Java多线程之 concurrent 并发包
2012-11-01 07:47 2021Java Tutorials -> Concur ... -
未完 Java Tips & Tricks & Notes
2012-09-12 10:00 1126Hidden Features of Java: h ... -
未完 Java Socket
2012-09-12 08:42 1013Java SocketJava SocketJava Sock ... -
Java For-each Loop & Iterable | 增强型For循环和Iterable接口
2012-09-11 21:50 2058增强型For循环没什么好说的,Just see link ... -
未完 Java Collections | 容器
2012-09-06 11:35 1830Sources: http://docs.oracle.com ... -
Java object Initialization (class Instantiation) | 对象的初始化(即类的实例化)
2012-09-03 09:12 3002类实例即对象 ... -
未完Java class&interfac 's Loading, Linking and Initializing | 类与接口的加载、链接和初始化
2012-08-31 19:01 1670JVM装载一个类的时候,首先检查他有没有父类,如果有父类则装载 ... -
未完 java Static 总结
2012-08-31 18:47 1402static可以用来修饰: 字段 Fields 方法 Meth ... -
Java Data Types & Literals | 数据类型 和 字面量
2012-08-30 18:12 3939Java数据类型划分: OR http:// ... -
未完 Variables 变量 (Instance/Class/Local)
2012-08-29 10:59 1699Local/Instance/Class Variables ... -
未完 Regular Expressions | 正则表达式
2011-08-25 11:43 1528Extended Regular Expression ... -
java Date(util.Date/sql.Date/sql.Timestamp/sql.Time) & Oracle DATE Type 时分秒 精度问题
2011-05-17 09:32 3958遇到的问题描述: 数据库为Oracle,其jdbc驱动为ojd ... -
Java byte code (bytecode)
2011-05-04 02:55 3883keys: bytecode, byte code, opco ... -
Java Classloading Mechanism : ClassLoader & ASM & 动态字节码增强
2011-04-21 13:29 2424Setting the class path: http:// ... -
class literal & instance.getClass() & Class.forName(String className)
2011-04-20 12:33 2335常用的几种取得Class类实例的方式: 1 class lit ... -
Java 数值计算
2011-04-20 02:44 2119java.lang.Math's floor(),ceil() ...
相关推荐
《Java Memory Model》是一篇关于Java内存模型的重要论文,由Jeremy Manson、William Pugh以及Sarita V. Adve共同撰写。该论文主要介绍了Java 5.0版本中更新后的Java内存模型(JMM),并详细阐述了它在多线程程序中...
java JVM Runtime Data Area and Instruction Set
本资料总结主要关注JVM内存分配及其运行原理,这对于理解和优化Java应用程序的性能至关重要。 1. **JVM内存结构** JVM内存分为几个关键区域:方法区(Method Area)、堆(Heap)、栈(Stack)、程序计数器(PC ...
Java JVM(Java虚拟机)内存分配与调优是Java开发者必须掌握的重要技能,它涉及到程序的性能优化和稳定性。在Java应用中,JVM扮演着至关重要的角色,它负责解析字节码、管理内存以及执行线程等。本文将深入探讨JVM...
### JVM内存空间分配详解 #### 一、JVM内存模型概览 ...综上所述,理解JVM内存分配机制对于Java开发者来说至关重要,这不仅有助于编写高效、稳定的代码,还能在遇到性能瓶颈时快速定位问题并进行优化。
在Java编程语言中,了解和控制JVM(Java虚拟机)的内存管理是至关重要的,尤其是在性能调优、资源管理和避免内存泄漏等方面。本文将深入探讨如何在Java中获取JVM内存大小,包括堆内存的总量、最大值以及剩余空间,并...
### Java 虚拟机JVM内存模型知识点 #### 1. JVM概述 ##### 1.1 Java的特性与JVM的应用 ...在实际开发过程中,合理配置JVM参数、选择合适的垃圾收集器和优化内存分配策略是提升Java应用性能的关键。
Java 实现内存动态分配主要涉及Java内存模型以及内存管理机制,包括堆内存和栈内存的分配,以及垃圾回收等概念。下面将详细解释这些知识点。 1. **Java内存模型** Java程序运行时,内存分为堆内存(Heap)和栈内存...
1. **Java内存模型**:深入解析了JMM(Java Memory Model),它是多线程环境下保证数据一致性的重要机制。 2. **JVM性能调优**:介绍了如何通过监控和调整JVM参数来优化应用程序的性能。 3. **JNI(Java Native ...
Java虚拟机(JVM)内存结构是Java程序运行的基础,它将内存划分为若干个不同的数据区域,包括堆、栈、方法区、程序计数器、本地方法栈和运行时常量池。这些区域各自有着特定的用途。例如,堆是所有线程共享的内存...
《深入理解Java虚拟机》是一本深度探讨Java虚拟机(JVM)的著作,涵盖了JVM性能调优、内存模型以及虚拟机原理等多个关键领域。本文将基于这些主题,详细阐述其中的重要知识点。 首先,我们要了解Java虚拟机(JVM)...
"Java JVM内存模型" Java虚拟机(JVM)内存模型是Java虚拟机的核心组件之一,它定义了Java程序在运行时的内存布局和管理方式。JVM内存模型主要分为五个部分:程序计数器、虚拟机栈、本地方法栈、堆、方法区。 1. ...
标题中提到了JVM原理、JVM调优、JVM内存模型和JAVA并发,这些都是Java虚拟机(JVM)相关的核心概念。JVM是运行Java字节码的虚拟计算机,为Java提供了一个跨平台的环境,确保Java程序可以在不同的操作系统上运行而...
Java程序在运行时的内存分配是一个关键的概念,它关乎到程序的性能、稳定性和资源管理。这个主题主要涉及以下几个方面: 1. **JVM内存结构**:Java虚拟机(JVM)将内存划分为几个区域,包括堆(Heap)、栈(Stack)...
### Java中堆内存与栈内存分配浅析 #### 一、引言 在Java编程语言中,内存管理是一项至关重要的技术。程序运行时所使用的内存主要分为两类:堆内存(Heap Memory)和栈内存(Stack Memory)。理解这两种内存类型的...
Java内存分配原理是Java编程中的重要一环,它关乎到程序的性能、稳定性和资源管理。深入理解这一主题,能够帮助开发者编写出更高效、更稳定的代码。在Java中,内存分为堆内存、栈内存、方法区(在Java 8之后被元空间...
其中,堆内存是Java对象的主要存储场所,栈内存主要存储方法调用时的局部变量,而方法区则存储类的信息,如类的常量池、字段和方法数据等。 内存泄漏通常发生在堆内存中,当程序创建对象并分配内存后,如果不再需要...
JVM内存模型是Java虚拟机的核心组件之一,它直接影响着Java应用程序的性能和可靠性。本文将深入剖析JVM内存模型的结构和工作机理,并讨论如何优化JVM参数以提高Java应用程序的性能。 一、JVM内存模型结构 JVM内存...
Java虚拟机(JVM)是Java程序的核心组成部分,它负责执行字节码并管理内存。在JVM的学习中,理解其内存模型、垃圾收集算法以及类加载机制至关重要。 1. **JVM内存模型** - **方法区**:也称为“永久代”,存储...
- **内存分配策略**:根据对象生命周期调整新生代和老年代的比例,避免Full GC频繁发生。 - **类加载机制优化**:合理控制类加载,避免类的过早加载和过多加载。 2. **虚拟机栈优化**: - **栈容量调整**:根据...