原文地址 https://javapapers.com/java/j...java
In Java, allocation and de-allocation of memory space for objects are done by the garbage collection process in an automated way by the JVM. Unlike C language the developers need not write code for garbage collection in Java. This is one among the many features that made Java popular and helps programmers write better Java applications.
在 Java 中,对用于存储对象的内存空间的分配和回收是 JVM 经过垃圾收集器自动完成的。与 C 语言不一样,Java 编程者不须要手工写垃圾回收的语句。这是 Java 之因此变得流行的众多因素之一,它让编程者能写出更好的 Java 应用。编程
This is a four part tutorial series to know about the basics of garbage collection in Java,
本系列文章一共包含四篇,介绍 Java 垃圾回收的基本知识:segmentfault
This tutorial is the first part in the series. It will explain the basic terminologies like JDK, JVM, JRE, HotSpot VM then understand the JVM architecture and Java heap memory structure. It is important to understand these basic things before going into the Garbage collection tutorial.
本文是系列中的第一部分,将介绍一些基本的技术名词好比 JDK、JVM、JRE、HotSpot VM,以帮助读者了解 JVM 的架构和 Java 堆内存的结构。想要深刻了解垃圾回收的话,了解这些基本概念十分重要。架构
Each JVM implementation may be different in the way the garbage collection principles are implemented. Prior to SUN takeover Oracle had JRockit JVM and after takeover it got the HotSpot JVM. Presently Oracle maintains both the JVM implementations and it has declared that over a period these two JVM implementations will be converged to one.
不一样的虚拟机实如今垃圾回收的实施原则上有所不一样。在 SUN 被 Oracle 收购以前,其产品是 JRockit 虚拟机,以后是 HotSpot 虚拟机。目前 Oracle 同时维护这两个虚拟机实现,并计划在未来某个时间将二者结合到一块儿。app
HotSpot JVM is available as a core component as part of the standard Oracle SE platform. In this garbage collection tutorial, we will see the garbage collection principles based on the HotSpot Virtual Machine.
HotSpot 虚拟机是标准的 Oracle SE 平台的核心部分。在本教程中,咱们将了解基于 HotSpot 虚拟机的垃圾回收原则。工具
Following diagram summarizes the key components in a JVM. In the JVM architecture, two main components that are related to garbage collection are heap memory and garbage collector. Heap memory is the runtime data area where the instances will be store and the garbage collector will operate on. Now we know how these things fit in the larger scheme.
下图大体展现了 JVM 的关键部件。在 JVM 架构中,两个部件与垃圾回收相关:堆内存(Heap Memory)和垃圾回收器(Garbage Collector)。堆内存是存放数据的内存区域,用来在运行期间保存对象实例,垃圾回收器的工做也是在堆内存当中进行的。如今咱们已经在大尺度方面了解了它们之间是如何配合的。this
It is essential to understand the role of heap memory in JVM memory model. At runtime the Java instances are stored in the heap memory area. When an object is not referenced anymore it becomes eligible for eviction from heap memory. During garbage collection process, those objects are evicted from heap memory and the space is reclaimed. Heap memory has three major areas,
理解堆内存在 JVM 内存模型中的角色是很是必要的。Java 对象实例在程序运行期间存储在堆内存中。当一个对象再也不被外部引用时,它就有了被回收的资格。在垃圾回收处理期间,此类对象都会被回收,其占用的内存会被释放。堆内存由三个主要区域组成:spa
Young Generation
(新生代)操作系统
Update: Permanent Generation (Permgen) space is removed from Java SE 8 features.
更新:从 Java 8 开始,堆内存模型中再也不包含永久区。翻译
In this next part of this tutorial series we will see about how garbage collection works in Java.
在下一篇文章中,咱们将了解垃圾回收的运行机理。