- 浏览: 479485 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
alvin198761:
renzhengzhi 写道我参与过12306余票查询系统的开 ...
别给12306 辩解了 -
renzhengzhi:
我参与过12306余票查询系统的开发,用户请求被前面3层缓存拦 ...
别给12306 辩解了 -
renzhengzhi:
写的很好。
JAVA线程dump的分析 -
liyonghui160com:
说好的附件呢
分布式服务框架 Zookeeper -- 管理分布式环境中的数据 -
ghpaas:
orbeon作为xforms标准的实现,不论其设计器还是运行时 ...
XForms 1.1 中文翻译—第1章 关于XForms标准
原文下载:IBM Garbage Collection and Storage Allocation Techniques
1 Introduction
This document describes the functions of the Storage (ST) component from release 1.2.2
to 1.4.1, Service Refresh 1. (IBM JDK5.0/6.0没有发布最新文档)
The ST component allocates areas of storage in the heap. These areas of storage define
objects, arrays, and classes. When an area of storage has been allocated, an object
continues to be live while a reference (pointer) to it exists somewhere in the active state
of the JVM; thus the object is reachable. When an object ceases to be referenced from
the active state, it becomes garbage and can be reclaimed for reuse. When this
reclamation occurs, the Garbage Collector must process a possible finalizer and also
ensure that any monitor that is associated with the object is returned to the pool of
available monitors (sometimes called the monitor cache). Not all objects are treated
equally by the ST component. Some (ClassClass and Thread) are allocated into special
regions of the heap (pinned clusters)(类和线程被分配到堆的特定区域); others (Reference and its derivatives) are treated
specially during tracing of the heap. More details on these special cases are given in
section 4.4 “Reference Objects”.
1.1 Object allocation
Object allocation is driven by calls to one of the allocation interfaces; for example,
stCacheAlloc, stAllocObject, stAllocArray, stAllocClass(这些函数没见过。。。). These interfaces all allocate a given amount of storage from the heap, but have different parameters and semantics. The
stCacheAlloc(用于小对象) routine is specifically designed to deliver optimal allocation performance
for small objects. Objects are allocated directly from a thread local allocation buffer that
the thread has previously allocated from the heap.(对象从线程之前对分配来的本地缓存中获取空间) A new object is allocated from the end
of this cache without the need to grab the heap lock(新对象无需获取堆的锁即可分配空间,效率很高); therefore, it is very efficient. Objects
that are allocated through the stAllocObject and stAllocArray interfaces are, if small
enough (currently 512 bytes), also allocated from the cache.
1.2 Reachable Objects
The active state of the JVM is made up of the set of stacks that represents the threads, the
static’s that are inside Java classes, and the set of local and global JNI references(堆包含线程所用栈、类的静态变量和本地、全局JNI引用集合). All
functions that are invoked inside the JVM itself cause a frame on the C stack. This
information is used to find the roots. These roots are then used to find references to other
objects. This process is repeated until all reachable objects are found.
1.3 Garbage Collection
When the JVM cannot allocate an object from the current heap because of lack of space,
the first task is to collect all the garbage that is in the heap. This process starts when any
thread calls stGC either as a result of allocation failure, or by a specific call to
System.gc()(引起完整GC?). The first step is to get all the locks that the garbage collection process needs. (第一步是获取垃圾回收所需的全部锁)
This step ensures that other threads are not suspended while they are holding critical
locks. All the other threads are then suspended through an execution manager (XM)
interface, which guarantees to make the suspended state of the thread accessible to the
calling thread. This state is the top and bottom of the stack and the contents of the
registers at the suspension point. It represents the state that is required to trace for object
references. Garbage collection can then begin. It occurs in three phases:
y Mark
y Sweep
y Compaction (optional)
1.3.1 Mark Phase
In the mark phase, all the objects that are referenced from the thread stacks, static’s,
interned strings, and JNI references are identified. This action creates the root set of
objects that the JVM references. Each of those objects might, in turn, reference others.
Therefore, the second part of the process is to scan each object for other references that it
makes. These two processes together generate a vector that defines live objects.
Each bit in the vector (allocbits) corresponds to an 8-byte section of the heap.(矢量中的每个bit代表了堆的一个8字节区域) The
appropriate bit is set when an object is allocated. When the Garbage Collector traces the
stacks, it first compares the pointer against the low and high limits of the heap. It then
ensures that the pointer is pointing to an object that is on an 8-byte boundary (GRAIN)
and that the appropriate allocbit is set to indicate that the pointer is actually pointing at an
object. The Garbage Collector now sets a bit in the markbits vector to indicate that the
object has been referenced.
Finally, the Garbage Collector scans the fields of the object to search for other object
references that the object makes. This scan of the objects is done accurately because the
method pointer that is stored in its first word enables the Garbage Collector to know the
class of the object. The Garbage Collector therefore has access to a vector of offsets that
the classloader builds at class linking time (before the creation of the first instance). The
offsets vector gives the offset of fields that are in the object that contains object
references. (垃圾回收器可以通过类的定义找到对象字段引用)
1.3.2 Sweep Phase
After the mark phase, the markbits vector contains a bit for every reachable object that is
in the heap. The markbits vector must be a subset of the allocbits vector. The task of the
sweep phase is to identify the intersection(交集) of these vectors; that is, objects that have been
allocated but are no longer referenced.
The original technique for this sweep phase was to start a scan at the bottom of the heap,
and visit each object in turn. The length of each object was held in the word that
immediately preceded it on the heap. At each object, the appropriate allocbit and markbit
was tested to locate the garbage.
Now, the bitsweep technique avoids the need to scan the objects that are in the heap and
therefore avoids the associated overhead cost for paging(换页). In the bitsweep technique, the
markbits vector is examined directly to look for long sequences of zeros (not marked),
which probably identify free space. When such a long sequence is found, the length of
the object that is at the start of the sequence is examined to determine the amount of free
space that is to be released.
1.3.3 Compaction Phase
After the garbage has been removed from the heap, the Garbage Collector can compact
the resulting set of objects to remove the spaces that are between them. Because
compaction can take a long time, it is avoided if possible(压缩耗时). Compaction, therefore, is a rare
event. Compaction avoidance is explained in more detail later in section “4.3.1
Compaction Avoidance”.
The process of compaction is complicated because handles are no longer in the JVM. If
any object is moved, the Garbage Collector must change all the references that exist to it.
If one of those references was from a stack, and therefore the Garbage Collector is not
sure that it was an object reference (it might have been a float, for example), the Garbage
Collector cannot move the object. (如果引用来自于栈,垃圾回收器不敢确定它是否是对象引用,也可能是浮点数比如,所以垃圾回收器不能移动对象)Such objects that are temporarily fixed in position are
referred to as dosed in the code and have the dosed bit set in the header word to indicate
this fact. Similarly, objects can be pinned during some JNI operations. Pinning has the
same effect, but is permanent until the object is explicitly unpinned by JNI. Objects that
remain mobile are compacted in two phases by taking advantage of the fact that the mptr
is known to have the low three bits set to zero. One of these bits can therefore be used to
denote the fact that it has been swapped. Note that this swapped bit is applied in two
places: the link field (where it is known as OLINK_IsSwapped), and also the mptr (where
it is known as GC_FirstSwapped). In both cases, the least significant bit (x01) is being
set.
At the end of the compaction phase, the threads are restarted through an XM interface.
发表评论
-
.NET开源核心运行时,且行且珍惜
2014-12-25 15:39 1859背景 2014年11月12日,ASP.NET之父、微软云 ... -
常用 Java Profiling 工具的分析与比较
2010-08-15 22:04 1180相对于静态代码分析,Profiling 是通过收集程序运行 ... -
监控系统内存
2010-07-01 14:15 1214public CollectorThread(int seco ... -
Debugging the JNI
2010-06-18 14:03 996If you think you have a JNI p ... -
JNI原理2
2010-06-18 13:31 159915.2 调用C程序 JNI规范 ... -
JNI原理1
2010-06-18 13:14 1260在某些Java的忠实支持者眼中,JNI(Java Nati ... -
JNI的crash终于搞定<转>
2010-06-18 13:08 1677今天终于搞定困扰我一周的一个问题了。我们的算法通过jni封装, ... -
java的volatile是什么意思
2010-04-20 15:39 1334我们知道,在Java中设置变量值的操作,除了long和d ... -
Concurrent kickoff
2010-04-19 15:55 1384This example shows you the ... -
IBM JDK和sun jdk区别
2010-04-19 15:52 2578在IBM的虚拟机官方指导文档中明确指出,禁止将虚拟机的最大 ... -
如何在IBM JDK 1.4.2的环境中避免Java堆空间的碎片问题
2010-04-19 15:48 875用户在使用WebSphere Applic ... -
Concurrent mark
2010-04-15 19:39 1016Concurrent mark gives reduced ... -
Java 技术,IBM 风格: 垃圾收集策略,第 1 部分
2010-04-15 16:51 984可以使用 4 种不同的策略配置 IBM Developer ... -
Java 网页浏览器组件介绍
2010-04-12 23:44 1503前言 在使用 Java 开发客户端程序时,有时会需要在界 ... -
利用 Java dump 进行 JVM 故障诊断
2010-04-06 16:54 1966引言 对于大型 java 应用程序来说,再精细的测试都难 ... -
Java 理论与实践: 垃圾收集简史
2010-04-06 14:34 818垃圾收集的好处是无 ... -
关注性能: 调优垃圾收集
2010-04-06 14:08 828随着网志作为公共日 ... -
Java 理论与实践: JVM 1.4.1 中的垃圾收集
2010-04-06 10:42 886老对象和年轻对象 ... -
优化 Java 垃圾收集器改进系统性能
2010-04-02 16:05 902From http://www.ibm.com/de ... -
搞懂java中的synchronized关键字
2010-04-01 19:54 812实际上,我关于java的基 ...
相关推荐
- **垃圾回收(GC)原理**:了解如何自动回收不再使用的对象,以及不同垃圾收集器的工作机制。 - **内存泄漏**:理解内存泄漏的原因,如全局变量、静态集合、线程池未关闭等。 - **对象引用**:强引用、软引用、...
JVM通过解析特定的二进制文件格式——Class文件来执行Java字节码。Class文件包含了JVM指令集、符号表以及辅助信息。 Class文件的结构基于两种数据类型:无符号数和表。无符号数是基本的数据类型,使用u1、u2、u3、...
通过分析这个日志,开发者和运维人员可以了解垃圾收集器的行为,包括何时启动、耗时多久、回收了多少内存等,这对于调整JVM参数以优化WebSphere性能至关重要。例如,如果频繁的垃圾收集导致应用暂停时间过长,可能...
**GCCollector——深入理解垃圾回收与性能优化** 在Java编程语言中,内存管理是一个关键的概念,特别是垃圾收集(Garbage Collection, GC)机制。GC是自动进行内存清理的一种技术,它负责识别并释放不再使用的对象...
### Tomcat性能优化 ...综上所述,通过合理配置JVM参数和垃圾回收策略,可以在很大程度上避免Tomcat中的内存溢出问题,进而提升其整体性能。此外,选择合适的虚拟机版本也是提高性能的重要步骤之一。
手册针对的是Oracle Hotspot和OpenJDK的行为,对于其他如jRockit或IBM J9等JVM的运行时环境,本手册中涉及的内容可能有所不同。 垃圾收集是自动内存管理的一个过程,其主要目的是找到并清理不再使用的对象,释放...
《Java虚拟机(第二版)》一书涵盖了Java开发与运行环境的核心部分——Java虚拟机(JVM)的深入解析。这本书旨在帮助读者理解JVM的工作原理,优化Java应用程序的性能,并解决运行时可能出现的问题。 Java自1995年...
- 对于IBM虚拟机,建议将`-Xms`设置为应用所需的最小值,以提高垃圾回收效率。 ##### 2.1.2 操作系统性能优化 - **HP-UX示例**:在HP-UX系统中,以下参数对Tomcat的影响较大: - `max_thread_proc`:一个进程所...
5. **JVM**:理解内存模型,包括堆、栈、方法区、本地方法栈等,以及垃圾回收机制。 6. **设计模式**:熟悉常见的设计模式,如单例、工厂、装饰器、观察者等,并能结合实际问题应用。 7. **Spring框架**:了解依赖...
- JVM中的引用类型包括强引用、软引用、弱引用和虚引用,其中软引用可以帮助加速垃圾回收过程。 - **GC分代回收机制**: - 堆被分为Young(年轻代)、Tenured(年老代)和Perm(持久代)。 - 不同类型的垃圾收集...
为了优化垃圾回收,勾选“详细垃圾回收”,并添加通用JVM参数:-XX:+UseParallelGC -Dfile.encoding=UTF-8 -XX:PermSize=256M -DenvironmenTypeCode=DevEnvironment -Dfile.encoding=GBK。这些参数有助于提高性能和...
它可能包括Java的平台独立性(Java虚拟机JVM)、面向对象特性、垃圾回收机制等内容。 2. **第四章 软件开发周期简介**:这部分内容可能讲解了软件开发的基本流程,包括需求分析、设计、编码、测试和维护等阶段,...
【J2EE企业级项目开发-3期(KC007) 3.4 消息中间件】是针对企业级应用开发中的一个重要组件——消息中间件进行深度探讨的课程内容。消息中间件在现代软件架构中扮演着关键角色,它负责在分布式系统中的不同组件之间...
第一部分 Hadoop——一种分布式...23612.4 搭建面向企业查询的分析系统——IBM的ES2项目 23812.4.1 ES2系统结构 24012.4.2 ES2爬虫 24112.4.3 ES2分析 24212.4.4 小结 24912.4.5 参考文献 250附录A HDFS文件命令 251
- 其他特点包括面向对象、安全性、高性能、可移植性、解释执行和自动垃圾回收等,这些将在进一步的学习中深入理解。 4. **Java标准组织——JCP(Java Community Process)**: JCP是一个开放的国际组织,负责Java...
3. `J9TraceFormat.dat`:可能与IBM J9 JVM的追踪格式相关,perf可以捕获并分析这些追踪数据,以理解JVM的内部行为。 4. `ir.idl` 和 `orb.idl`:这些可能是接口定义语言(IDL)文件,用于跨进程通信。perf可能用于...
1. **跨平台性**:Java的这一特性源于其“字节码”概念,即Java源代码被编译成一种中间格式——字节码,然后由Java虚拟机(JVM)解释执行,从而实现了平台独立性。 2. **安全性**:Java提供了严格的访问控制机制和...
Java的平台独立性得益于其独特的运行时环境——Java虚拟机(JVM),它能够解释字节码,让Java程序能够跨平台运行。面向对象的特性让Java的程序设计更加模块化和可复用。Java支持多线程,这使得可以同时执行多个任务...
- **打开heap dump**:MAT支持多种格式的heap dump文件,如标准的JVM dump或IBM J9 dump。用户只需通过"File" -> "Open Heap Dump"菜单导入文件。 - **概览视图**:在主界面,可以看到一个概览图,显示堆内存的...