探索JVM的堆内存分布:官方图片展示

news/2024/10/5 7:10:04

 

序章

截取Java官方的 堆内存分布相关图片 到本文。

 

Java Platform, Standard Edition

HotSpot Virtual Machine Garbage Collection Tuning Guide

Java 21

https://docs.oracle.com/en/java/javase/21/gctuning/preface.html

下载为 pdf,搜索 Figure,截取其中的 堆内存分布相关的图片 到本文。

 

原来,堆内存 是由 垃圾回收器 分配的,不同的 垃圾回收器 有不同的分配规则。

 

Figure 3-2 Default Arrangement of Generations in the Serial Collector

原文:

At startup, the Java HotSpot VM reserves the entire Java heap in the address space, but
doesn't allocate any physical memory for it unless needed.

The entire address space covering the Java heap is logically divided into young and old generations. The complete address space
reserved for object memory can be divided into the young and old generations.

bing.com 翻译:

启动时,Java HotSpot VM 会在地址空间中保留整个 Java 堆,但除非需要,否则不会为其分配任何物理内存。

覆盖 Java 堆的整个地址空间在逻辑上分为新代和老代。为对象内存保留的完整地址空间可分为新代和老代。

The young generation consists of eden and two survivor spaces. Most objects are initially allocated in eden. 
One survivor space is empty at any time, and serves as the destination of live objects in eden and the other survivor space during garbage collection; 
after garbage collection, eden and the source survivor space are empty. 
In the next garbage collection, the purpose of the two survivor spaces are exchanged. 
The one space recently filled is a source of live objects that are copied into the other survivor space. 
Objects are copied between survivor spaces in this way until they've been copied a certain number of times or there isn't enough
space left there. 
These objects are copied into the old region. 
This process is also called aging.

bing.com 翻译:

年轻一代由 eden 和两个幸存者空间组成。大多数对象最初是在 eden 中分配的。
一个幸存者空间在任何时候都是空的,并作为 eden 中活动对象的目的地,在垃圾回收期间充当另一个幸存者空间的目的地;
垃圾回收后,Eden 和 Source Survivor Space 为空。
在下一次垃圾回收中,将交换两个幸存者空间的用途。
最近填充的一个空间是被复制到另一个幸存空间的活动对象的源。
以这种方式在幸存者空间之间复制对象,直到它们被复制一定次数或没有足够的时间
那里留有空间。
这些对象将复制到旧区域中。
这个过程也称为老化。

 

Figure 4-1 Heap Options

堆参数。

 

Figure 6-1 Arrangement of Generations in the Parallel Collector

 

Figure 7-1 G1 Garbage Collector Heap Layout

原文:

The young generation contains eden regions (red) and survivor regions (red with "S"). 
These regions provide the same function as the respective contiguous spaces in other collectors, 
with the difference that in G1 these regions are typically laid out in a noncontiguous pattern in memory. 
Old regions (light blue) make up the old generation. Old generation regions may be humongous (light blue with "H") for objects that span multiple regions.

bing.com 翻译:

新生代包含 eden 区域(红色)和幸存区域(红色,带“S”)。
这些区域提供与其他收集器中相应的连续空间相同的功能。
不同的是,在 G1 中,这些区域通常在内存中以非连续模式布局。
旧区域(浅蓝色)构成了老一代。对于跨多个区域的对象,老一代区域可能很大(带“H”的浅蓝色)。

An application always allocates into a young generation, that is, eden regions, with the exception of humongous objects that are directly allocated as belonging to the old generation.

bing.com 翻译:

应用程序始终分配给新生代,即 eden 区域,但直接分配为属于老一代的巨大对象除外。

 

Figure 7-2 Garbage Collection Cycle Overview

图片下方有 各个阶段的介绍,可取原文查看。

 

小结

官文中 的图片 展示了 Serial、Parallel、G1 三种 垃圾回收器 的 堆内存分布。

当然,官文还有更多丰富的内容,请自行学习。

 

Java 8

链接:

https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/

没找到 pdf 下载入口。

 

Figure 3-2 Default Arrangement of Generations, Except for Parallel Collector and G1

图片描述(Description of):

 

Figure 4-1 Heap Parameters

Description of:

Figure 6-1 Arrangement of Generations in the Parallel Collector

Description of:

 

Figure 9-1 Heap Division by G1

Description of:

The figure consists of a 10-by-10 grid. Most of the grid's cells are gray.

Nineteen cells are colored dark blue.

These dark blue cells are randomly distributed in the upper six rows of the grid.

Two of these dark blue cells contain a red box.

A cell two cells wide and one cell high (which appears in the first row) and a cell three cells wide and one cell high (which appears in the sixth row) are colored dark blue and labeled "H."

Eight cells are colored light blue and contain a red box.

Two of these cells are labeled "S."

These light blue cells with a red box are distributed randomly, most of them located in the upper half of the grid.

bing.com 翻译:

该图由一个 10 x 10 的网格组成。网格的大多数单元格都是灰色的。

19 个细胞为深蓝色。

这些深蓝色单元格随机分布在网格的上六行中。

其中两个深蓝色单元格包含一个红色框。

一个单元格宽 2 个单元格,高 1 个单元格(显示在第一行中)和一个单元格宽 3 个单元格,高 1 个单元格(显示在第六行中)为深蓝色,并标记为“H”。

八个单元格为浅蓝色,并包含一个红色框。

其中两个单元格标记为 “S”。

这些带有红色框的浅蓝色单元格是随机分布的,其中大多数位于网格的上半部分。

 

---END---

 

本文链接:

https://www.cnblogs.com/luo630/p/18446638

 

ben发布于博客园

ben发布于博客园

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.ryyt.cn/news/67886.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

相关文章

快乐数学3勾股定理延伸

3 勾股定理延伸 我们一直低估了勾股定理。上一章表明它适用于任何有平方项的公式。 3.1 理解该定理在任意直角三角形中如果 a=3 和 b=4,那么 c=5。很简单吧?那么,关键的一点是 a 和 b 成直角(注意小红框)。一个方向的移动对另一个方向没有影响。 这有点像南北与东西的关系…

Docker系列-超级详细教你Linux安装并使用docker compose,如何使用docker-compose安装sqlserver

docker compose是什么? Docker Compose 和docker功能一样,为了运行容器服务,但是docker compose比docker更好的一点是:允许你在一个 YAML 文件中定义多个容器及其配置,并通过一条命令启动和管理这些容器。 为什么要使用docker compose? 通过 Compose,您可以使用 YML 文件…

手把手非常详细图文并茂教你 Docker 部署 SQL Server

前提条件linux服务器 服务器装好了Docker 引擎 1.8 及更高版本 至少 2 GB 的磁盘空间 至少 2 GB 的 RAM搜索镜像 docker search mssql-server拉取镜像 找到适合你的版本,拉取镜像,下面这个是我从官方文档里直接找到的镜像哇~ docker pull mcr.microsoft.com/mssql/server:202…

git报错集

报错集 1.打标签报错 前戏:在开发了基础的项目功能后,在推送到远端仓库后,打算给提交的版本打标签,报错了 $ git push origin --tags fatal: unable to access https://github.com/ICP-team/仓库名.git/: Failed to connect to github.com port 443 after 21072 ms: Could…

财务知识-20个常用的会计分录

财务知识——20个常用的会计分录

[rCore学习笔记 029] 动态内存分配器实现-以buddy_system_allocator源码为例

在上一部分,我们讲了动态内存分配器的原理是维护一个堆,而且是实现各种连续内存分配方法. 但是上一部分是直接通过引用了buddy_system_allocator来解决的问题. 那么对于内存分配算法有兴趣的我,还是决定看一下源码,总之人是咸鱼但是还是需要有梦想. 人生这么不顺,若是连梦想都没…

工具推荐:搜索和删除Windows上重复文件的神器:AllDup

​ AllDup是一款免费的重复文件查找工具,它能够帮助用户快速识别和管理计算机上的重复文件。这些文件可能包括文本、图片、音乐、视频等多种类型。AllDup使用快速查询算法,可以有效地搜索和定位重复项,从而帮助用户释放硬盘空间,组织文件结构,并提高系统性能。 下载地址:h…

工具推荐:完全免费的电脑 Epub 阅读器软件 Jane Reader

​ Jane Reader是一款现代化的电子书阅读器,支持EPUB格式,旨在提供类似于纸质书籍的阅读体验。它具有简洁、清爽的界面,支持自动多栏、多主题、直排模式等功能,并提供了一系列个性化设置,如自定义边距、行高、字体大小等。Jane Reader还内置了常用字体,如宋体、黑体、仿宋…