Chen Jian

学习JVM原理-3. 什么对象可被GC? 何时GC?

摘自《深入理解Java虚拟机》周志明著 对象能否被GC,是根据对象关联图来决定的 (图论里的“图”) JVM会维持一张图,这个图里有些“根”结点, 如果从根到某个对象之间没有路径,则这个对象可以被GC. 这些根结点称作GC Roots,这种判断算法称作GC Roots Tracing Method Areas中的常量池的常量能否被GC,也是基于相同的原则; 至于Method Areas中的类,则要满足实例已回收、ClassLoader已回收和Bean.class对象未被引用等三个条件 不过,对象被判定未被引用之后并不会立即判死刑,它只会被放到一个队列中,系统会执行队列中每个对象的finalize()方法,在finalize()方法中对象可以把自己关联给别的对象,这样它就能逃出生天。然而,覆盖finalize()方法本身是不良的实践,应尽量避免。 对象被判死刑后并不意味着会立即执行,这取决于GC的调度算法,有的情况会频繁一些,有的则少一些,这取决于你使用的GC策略和当前的内存情况。

学习JVM原理-2.垃圾回收概述

摘自《深入理解Java虚拟机》周志明著 1. 哪些内存区域需要GC ? Runtime Data Areas中,Program Counter Register, VM Stack, Native Stack随方法/线程而生,随方法/线程而灭,这里基本不需要考虑内存回收的问题。 GC的讨论主要针对Heap和Method Area。 2. GC需要关心的问题   a.如何给对象判死刑?何时执行?    –可回收标准   b.对象是一个一个杀,还是成批的杀?  — 回收算法   c.对象杀之前关在哪里?  — 内存分配 这些问题会在本系列后面的博客中陈述

Memory Leak & Memory Overflow

转自Wikipedia Memory Leak : it occurs when a computer program consumes memory but is unable to release it back to the operating system. In object-oriented programming, a memory leak happens when an object is stored in memory but cannot be accessed by the running code. Memory Overflow : it occurs where a program, while writing …

Memory Leak & Memory Overflow Read More »

学习JVM原理-1. Runtime Data Areas

摘自《深入理解Java虚拟机》周志明著 Runtime Data Areas分为五大部分:    1. Program Counter Register: 当前线程所执行的字节码的行号指示器,这里不会产生内存溢出问题    2. VM Stack: Java方法执行的内存模型。每个方法会占用一个栈帧,用于存储局部变量表,对象引用等。如果存储前申请不到足够的内存,会抛OutOfMemoryError;另外,如果栈深度大于JVM所容许的最大深度,则会抛StackOverflowError    3. Native Method Stacks: 与VM Stack作用相似,只不过它只针对虚拟机用到的Native方法。它也会抛OutOfMemoryError和StackOverflowError.    4. Heap: 用于存放对象实例,也称作GC堆。会抛OutOfMemoryError    5. Method Area: 存放类信息,常量,静态变量等。按规范在此可以选择不实现垃圾收集,但实践证明这里的GC是必要的。这里也会抛OutOfMemoryError 另外,JVM可以用"Direct Memory"的方式直接操纵本地内存(如NIO),如果这里申请的内存超过了本机总内存,则JVM也会抛OutOfMemoryError 举例说明:    Bean bean = new Bean();       1. "Bean bean"将会存入到VM Stack的局部变量表中    2. new Bean()这个对象实例将会存入到 Heap中    3. Bean这个类相关的数据将存入到Method Area …

学习JVM原理-1. Runtime Data Areas Read More »

JAVA标准化的几个术语:JCP, JSR, RI, TCK

摘自wikipedia http://en.wikipedia.org/wiki/Java_Community_Process JCP — The Java Community Process or JCP, established in 1998, is a formalized process that allows interested parties to get involved in the definition of future versions and features of the Java platform. JSR — The JCP involves the use of Java Specification Requests (JSRs) – the formal documents that describe proposed …

JAVA标准化的几个术语:JCP, JSR, RI, TCK Read More »

学习JVM原理-国内JVM社区

虚拟机圈子: http://hllvm.group.iteye.com 莫枢的博客: http://rednaxelafx.iteye.com 周志明:   http://icyfenx.iteye.com/blog/1119214 周志明的微博: http://t.sina.com.cn/icyfenix

收藏一本书:分布式系统原理与范型

http://product.china-pub.com/40777 1 introduction  1.1 definition of a distributed system  1.2 goals   1.2.1 maing resources accessible   1.2.2 distribution transparency   1.2.3 openness   1.2.4 scalability   1.2.5 pitfalls  1.3 types of distributed systems   1.3.1 distributed compuhng systems   1.3.2 distributed information systems   1.3.3 distubuted pervasive systems  1.4 summary 2 architectures  2.1 architectural styles  2.2 system archctures   2.2.1 centralized architectures   2.2.2 …

收藏一本书:分布式系统原理与范型 Read More »