G1垃圾收集器官方文档透彻解读

G1官网地址:https://www.oracle.com/webfolder/technetwork/tutorials/obe/java/G1GettingStarted/index.html?source=:ow⭕️p:nav:0916BCButton

Getting Started with the G1 Garbage Collector

1. Overview

1.1 Purpose

​ This tutorial covers the basics of how to use the G1 garbage collector and how it can be used with the Hotspot JVM. You will learn how the G1 collector functions internally, the key command line switches for using G1, and options for logging its operation.

​ 本教程将介绍如何使用G1垃圾收集器以及如何将其与Hotspot JVM一起使用。您将了解G1收集器如何在内部运行,使用G1的关键命令行开关,以及记录其操作的选项。

1.2 Time to Complete

​ Approximately 1 hour

1.3 Introduction

​ This OBE covers the basics of Java Virtual Machine(JVM) G1 Garbage Collection (GC) in Java. In the first part of the OBE, an overview of the JVM is provided along with an introduction to Garbage Collection and performance. Next students are provided with a review of how the CMS collector works with the Hotspot JVM. Next, a step by step guide to how Garbage Collection works when using the G1 garbage collection with a Hotspot JVM. Following that, a section is provided covering the Garbage Collection command line options available with the G1 garbage collector. Finally, you will learn about logging options to use with the G1 collector.

​ 这个OBE涵盖了Java中Java虚拟机(JVM)G1垃圾收集(GC)的基础知识。在OBE的第一部分中,概述了JVM,并介绍了垃圾收集和性能。接下来的学生将回顾CMS收集器如何与Hotspot JVM一起工作。接下来,一个分步指南,介绍如何在Hotspot JVM中使用G1垃圾收集。接下来,将提供一个部分,介绍G1垃圾收集器可用的垃圾收集命令行选项。最后,您将了解与G1收集器一起使用的日志记录选项。

1.4 Hardware(硬件) and Software Requirements

The following is a list of hardware and software requirements:

  • A PC running Windows XP or later, Mac OS X or Linux. Note that the hands on is done with Windows 7 and has not been tested on all platforms. However, everything should work fine on OS X or Linux. Also a machine with more than one core is preferable.
  • Java 7 Update 9 or later
  • The latest Java 7 Demos and Samples Zip file

1.5 Prerequisites

Before starting this tutorial, you should:

  • If you have not done so, download and install the latest version of the Java JDK (JDK 7 u9 or later).
    Java 7 JDK Downloads
  • Download and install the Demos and Samples zip file from the same location. Unzip the file and place the contents in a directory. For example: C:\javademos

2. Java Technology and the JVM

2.1 Java Overview

​ Java is a programming language and computing platform first released by Sun Microsystems in 1995. It is the underlying technology that powers Java programs including utilities, games, and business applications. Java runs on more than 850 million personal computers worldwide, and on billions of devices worldwide, including mobile and TV devices. Java is composed of a number of key components that, as a whole, create the Java platform.

​ Java是Sun Microsystems于1995年首次发布的一种编程语言和计算平台。它是支持Java程序的底层技术,包括实用程序、游戏和业务应用程序。Java在全球超过8.5亿台个人电脑上运行,在全球数十亿台设备上运行,包括移动和电视设备。Java由许多关键组件组成,这些组件作为一个整体创建了Java平台。

2.1.1 Java Runtime Edition

​ When you download Java, you get the Java Runtime Environment (JRE). The JRE consists of the Java Virtual Machine (JVM), Java platform core classes, and supporting Java platform libraries. All three are required to run Java applications on your computer. With Java 7, Java applications run as desktop applications from the operating system, as a desktop application but installed from the Web using Java Web Start, or as a Web Embedded application in a browser (using JavaFX).

​ 下载Java时,您将获得Java运行时环境(JRE)。JRE由Java虚拟机(JVM)、Java平台核心类和支持Java平台库组成。所有这三个都需要在您的计算机上运行Java应用程序。在Java7中,Java应用程序作为桌面应用程序从操作系统运行,作为桌面应用程序但使用Java Web Start从Web安装,或者作为浏览器中的Web嵌入式应用程序(使用JavaFX)。

2.1.2 Java Programming Language

Java is an object-oriented programming language that includes the following features.

Java是一种面向对象的编程语言,它包括以下特性。

  • Platform Independence - Java applications are compiled into bytecode which is stored in class files and loaded in a JVM. Since applications run in a JVM, they can be run on many different operating systems and devices.

    平台独立性—Java应用程序被编译成字节码,字节码存储在class文件中并加载到JVM中。由于应用程序在JVM中运行,因此它们可以在许多不同的操作系统和设备上运行。

  • Object-Oriented - Java is an object-oriented language that take many of the features of C and C++ and improves upon them.

    面向对象——Java是一种面向对象的语言,它具有C和C++的许多特性并改进了它们。

  • Automatic Garbage Collection - Java automatically allocates and deallocates memory so programs are not burdened with that task.

    自动垃圾收集-Java自动分配和释放内存,这样程序就不会承担这个任务。

  • Rich Standard Library - Java includes a vast number of premade objects that can be used to perform such tasks as input/output, networking, and date manipulation.

    丰富的标准库-Java包含大量可用于执行输入/输出、网络连接和日期操作等任务的预制对象。

2.1.3 Java Development Kit

​ The Java Development Kit (JDK) is a collection of tools for developing Java applications. With the JDK, you can compile programs written in the Java Programming language and run them in a JVM. In addition, the JDK provides tools for packaging and distributing your applications.

​ Java Development Kit(JDK)是一组用于开发Java应用程序的工具。使用JDK,您可以编译用Java编程语言编写的程序并在JVM中运行它们。此外,JDK还提供了打包和分发应用程序的工具。

​ The JDK and the JRE share the Java Application Programming Interfaces (Java API). The Java API is a collection of prepackaged libraries developers use to create Java applications. The Java API makes development easier by providing the tools to complete many common programming tasks including string manipulation, date/time processing, networking, and implementing data structures (e.g., lists, maps, stacks, and queues).

​ JDK和JRE共享Java应用程序编程接口(Java API。Java API是开发人员用于创建Java应用程序的预打包库的集合。Java API通过提供工具来完成许多常见的编程任务,包括字符串操作、日期/时间处理、联网和实现数据结构(例如,列表、映射、堆栈和队列),使开发更加容易。

2.1.4 Java Virtual Machine

​ The Java Virtual Machine (JVM) is an abstract computing machine. The JVM is a program that looks like a machine to the programs written to execute in it. This way, Java programs are written to the same set of interfaces and libraries. Each JVM implementation for a specific operating system, translates the Java programming instructions into instructions and commands that run on the local operating system. This way, Java programs achieve platform independence.

​ Java虚拟机(JVM)是一种抽象的计算机器。JVM是一个程序,对于要在其中执行的程序来说,它就像一台机器。这样,Java程序就被写入到同一组接口和库中。针对特定操作系统的每个JVM实现,都将Java编程指令转换为在本地操作系统上运行的指令和命令。这样,Java程序就实现了平台无关性。

​ The first prototype implementation of the Java virtual machine, done at Sun Microsystems, Inc., emulated the Java virtual machine instruction set in software hosted by a handheld device that resembled a contemporary Personal Digital Assistant (PDA). Oracle’s current implementations emulate the Java virtual machine on mobile, desktop and server devices, but the Java virtual machine does not assume any particular implementation technology, host hardware, or host operating system. It is not inherently interpreted, but can just as well be implemented by compiling its instruction set to that of a silicon CPU. It may also be implemented in microcode or directly in silicon.

​ Java虚拟机的第一个原型实现是在Sun Microsystems,Inc.完成的,它模拟了Java虚拟机指令集,该指令集由类似于当代个人数字助理(PDA)的手持设备托管。Oracle当前的实现在移动、桌面和服务器设备上模拟Java虚拟机,但Java虚拟机不采用任何特定的实现技术、主机硬件或主机操作系统。它不是固有的解释,但也可以通过将其指令集编译为硅CPU的指令集来实现。它也可以用微码或直接用硅来实现。

​ The Java virtual machine knows nothing of the Java programming language, only of a particular binary format, the class file format. A class file contains Java virtual machine instructions (or bytecodes) and a symbol table, as well as other ancillary information.

​ Java虚拟机对Java编程语言一无所知,只知道特定的二进制格式,即类文件格式。类文件包含Java虚拟机指令(或字节码)和符号表以及其他辅助信息。

​ For the sake of security, the Java virtual machine imposes strong syntactic and structural constraints on the code in a class file. However, any language with functionality that can be expressed in terms of a valid class file can be hosted by the Java virtual machine. Attracted by a generally available, machine-independent platform, implementors of other languages can turn to the Java virtual machine as a delivery vehicle for their languages. (1) The Java Virtual Machine

​ 为了安全起见,Java虚拟机对类文件中的代码施加了很强的语法和结构约束。但是,任何具有可用有效类文件表示的功能的语言都可以由Java虚拟机托管。其他语言的实现者被一个普遍可用的、与机器无关的平台所吸引,可以将Java虚拟机作为其语言的传递工具。

2.2. Exploring the JVM Architecture

2.2.1 Hotspot Architecture

​ The HotSpot JVM possesses an architecture that supports a strong foundation of features and capabilities and supports the ability to realize high performance and massive scalability. For example, the HotSpot JVM JIT compilers generate dynamic optimizations. In other words, they make optimization decisions while the Java application is running and generate high-performing native machine instructions targeted for the underlying system architecture. In addition, through the maturing evolution and continuous engineering of its runtime environment and multithreaded garbage collector, the HotSpot JVM yields high scalability on even the largest available computer systems.

​ HotSpot JVM拥有一个支持特征和能力的强大基础架构,并支持实现高性能和大规模可扩展性的能力。例如,HotSpot JVM JIT编译器生成动态优化。换句话说,**它们在Java应用程序运行时做出优化决策,并生成针对底层系统架构的高性能本机指令。**此外,HotSpot JVM通过其运行时环境和多线程垃圾收集器的成熟演进和持续工程,在即使是最大的可用计算机系统上也能获得高的可伸缩性。
在这里插入图片描述
​ The main components of the JVM include the class loader, the runtime data areas, and the execution engine.

2.2.2 Key Hotspot Components

The key components of the JVM that relate to performance are highlighted in the following image.
在这里插入图片描述
​ There are three components of the JVM that are focused on when tuning performance. The heap is where your object data is stored. This area is then managed by the garbage collector selected at startup. Most tuning options relate to sizing the heap and choosing the most appropriate garbage collector for your situation. The JIT compiler also has a big impact on performance but rarely requires tuning with the newer versions of the JVM.

​ **在调整性能时,JVM有三个组件是重点关注的。**①堆是存储对象数据的地方。然后,该区域由启动时选择的垃圾收集器管理。②大多数优化选项都与调整堆大小和根据您的情况选择最合适的垃圾收集器有关。③JIT编译器对性能也有很大的影响,但很少需要使用较新版本的JVM进行调优。

2.3 Performance Basics

​ Typically, when tuning a Java application, the focus is on one of two main goals: responsiveness or throughput. We will refer back to these concepts as the tutorial progresses.

​ 通常,在调整Java应用程序时,重点是两个主要目标之一:响应性或吞吐量。随着教程的进行,我们将回顾这些概念

2.3.1 Responsiveness(响应性)

Responsiveness refers to how quickly an application or system responds with a requested piece of data. Examples include:

响应性是指应用程序或系统对请求的数据的响应速度。示例包括:

  • How quickly a desktop UI responds to an event

  • How fast a website returns a page

  • How fast a database query is returned

    For applications that focus on responsiveness, large pause times are not acceptable. The focus is on responding in short periods of time.

2.3.2 Throughput(吞吐量)

Throughput focuses on maximizing the amount of work by an application in a specific period of time. Examples of how throughput might be measured include:

吞吐量主要是指在特定的时间内使应用程序的工作量最大化。如何测量吞吐量的示例包括:

  • The number of transactions completed in a given time.

  • The number of jobs that a batch program can complete in an hour.

  • The number of database queries that can be completed in an hour.

    High pause times are acceptable for applications that focus on throughput. Since high throughput applications focus on benchmarks over longer periods of time, quick response time is not a consideration.

    对于注重吞吐量的应用程序,高暂停时间是可以接受的。由于高吞吐量应用程序将重点放在较长时间内的基准测试上,因此不考虑快速响应时间。

3. The G1 Garbage Collector

​ The Garbage-First (G1) collector is a server-style garbage collector, targeted for multi-processor machines with large memories. It meets garbage collection (GC) pause time goals with a high probability, while achieving high throughput. The G1 garbage collector is fully supported in Oracle JDK 7 update 4 and later releases. The G1 collector is designed for applications that:

​ 垃圾优先(G1)收集器是服务器风格的垃圾收集器,目标是具有大内存的多处理器计算机。它以很高的概率满足垃圾收集(GC)暂停时间目标,同时实现高吞吐量。在 Oracle JDK 7 Update 4和更高版本中完全支持G1垃圾收集器。G1收集器是为以下应用而设计的:

  • Can operate concurrently with applications threads like the CMS collector.

    可以与CMS收集器之类的应用程序线程同时操作。

  • Compact free space without lengthy GC induced pause times.

    紧凑的自由空间,没有长的GC诱导的暂停时间。

  • Need more predictable GC pause durations.

    需要更可预测的GC暂停时间。

  • Do not want to sacrifice a lot of throughput performance.

    不想牺牲很多吞吐量性能。

  • Do not require a much larger Java heap.

    不需要更大的Java堆。

​ G1 is planned as the long term replacement for the Concurrent Mark-Sweep Collector (CMS). Comparing G1 with CMS, there are differences that make G1 a better solution. One difference is that G1 is a compacting collector. G1 compacts sufficiently to completely avoid the use of fine-grained free lists for allocation, and instead relies on regions. This considerably simplifies parts of the collector, and mostly eliminates potential fragmentation issues. Also, G1 offers more predictable garbage collection pauses than the CMS collector, and allows users to specify desired pause targets.

​ G1计划作为并发标记扫描收集器(CMS)的长期替代品。与CMS相比,G1是一个更好的解决方案。一个区别是G1是一个压缩收集器。G1足够紧凑,完全避免使用细粒度的自由列表进行分配,而是依赖于区域。这大大简化了收集器的部分工作,并且基本上消除了潜在的碎片问题。此外,G1提供了比CMS收集器更可预测的垃圾收集暂停,并允许用户指定所需的暂停目标

3.1 G1 Operational Overview

​ The older garbage collectors (serial, parallel, CMS) all structure the heap into three sections: young generation, old generation, and permanent generation of a fixed memory size.

​ 旧的垃圾收集器(串行、并行、CMS)都将堆结构为三个部分:年轻一代、旧一代和固定内存大小的永久一代。
在这里插入图片描述
​ All memory objects end up in one of these three sections.

​ 所有的内存对象都会放在这三个部分中的一个部分。

​ The G1 collector takes a different approach.
在这里插入图片描述
​ The heap is partitioned into a set of equal-sized heap regions, each a contiguous range of virtual memory. Certain region sets are assigned the same roles (eden, survivor, old) as in the older collectors, but there is not a fixed size for them. This provides greater flexibility in memory usage.

​ 堆被划分为一组大小相等的堆区域,每个区域都是虚拟内存的连续区域。某些区域集被分配了与旧收集器中相同的角色(eden、survivor、old),但它们没有固定的大小。这为内存使用提供了更大的灵活性。

​ When performing garbage collections, G1 operates in a manner similar to the CMS collector. G1 performs a concurrent global marking phase to determine the liveness of objects throughout the heap. After the mark phase completes, G1 knows which regions are mostly empty. It collects in these regions first, which usually yields a large amount of free space. This is why this method of garbage collection is called Garbage-First. As the name suggests, G1 concentrates its collection and compaction activity on the areas of the heap that are likely to be full of reclaimable objects, that is, garbage. G1 uses a pause prediction model to meet a user-defined pause time target and selects the number of regions to collect based on the specified pause time target.

​ 在执行垃圾收集时,G1的操作方式与CMS收集器类似。G1执行一个并发的全局标记阶段,以确定整个堆中对象的活动性。标记阶段完成后,G1知道哪些区域大部分是空的。它首先聚集在这些区域,这通常会产生大量的自由(可用)空间。这就是为什么这种垃圾收集方法称为“垃圾优先”。顾名思义,G1将其收集和压缩活动集中在堆中可能充满可回收对象(即垃圾)的区域。G1使用暂停预测模型来满足用户定义的暂停时间目标,并基于指定的暂停时间目标选择要收集的区域数。

​ The regions identified by G1 as ripe for reclamation are garbage collected using evacuation. G1 copies objects from one or more regions of the heap to a single region on the heap, and in the process both compacts and frees up memory. This evacuation is performed in parallel on multi-processors, to decrease pause times and increase throughput. Thus, with each garbage collection, G1 continuously works to reduce fragmentation, working within the user defined pause times. This is beyond the capability of both the previous methods. CMS (Concurrent Mark Sweep ) garbage collector does not do compaction. ParallelOld garbage collection performs only whole-heap compaction, which results in considerable pause times.

​ 被G1确定为可回收的区域是通过疏散收集的垃圾。G1将对象从堆的一个或多个区域复制到堆的单个区域,在这个过程中压缩和释放内存。这种抽空在多个处理器上并行执行,以减少暂停时间并提高吞吐量。因此,对于每个垃圾收集,G1在用户定义的暂停时间内连续工作以减少碎片。这超出了前面两种方法的能力。CMS(并发标记扫描)垃圾收集器不进行压缩。Parallel Old垃圾收集执行整个堆压缩,这会导致相当长的暂停时间。

​ It is important to note that G1 is not a real-time collector. It meets the set pause time target with high probability but not absolute certainty. Based on data from previous collections, G1 does an estimate of how many regions can be collected within the user specified target time. Thus, the collector has a reasonably accurate model of the cost of collecting the regions, and it uses this model to determine which and how many regions to collect while staying within the pause time target.

​ 需要注意的是,G1不是实时收集器。它满足设定的暂停时间目标的概率很高,但不是绝对确定的。根据以前收集到的数据,G1估计在用户指定的目标时间内可以收集多少个区域。因此,收集器对收集区域的成本有一个相当精确的模型,并且它使用该模型来确定在停留在暂停时间目标内要收集哪些和多少区域。

Note: G1 has both concurrent (runs along with application threads, e.g., refinement, marking, cleanup) and parallel (multi-threaded, e.g., stop the world) phases. Full garbage collections are still single threaded, but if tuned properly your applications should avoid full GCs.

注意:G1既有并发(与应用程序线程一起运行,例如优化、标记、清理)阶段,也有并行(多线程,例如停止世界)阶段。完整的垃圾收集仍然是单线程的,但是如果调整得当,应用程序应该避免full gc。

3.2 G1 Footprint

​ If you migrate from the Parallel Old GC or CMS collector to G1, you will likely see a larger JVM process size. This is largely related to “accounting” data structures such as Remembered Sets and Collection Sets.

​ 如果从Parallel Old GC或CMS收集器迁移到G1,您可能会看到更大的JVM进程大小。这在很大程度上与“accounting”数据结构有关,如记忆集和集合集。

Remembered Sets or RSets track object references into a given region. There is one RSet per region in the heap. The RSet enables the parallel and independent collection of a region. The overall footprint impact of RSets is less than 5%.

RSets 将对象引用跟踪到给定区域。堆中每个区域有一个RSet。RSet支持区域的并行和独立集合。资源集的总体足迹影响小于5%

Collection Sets or CSets the set of regions that will be collected in a GC. All live data in a CSet is evacuated (copied/moved) during a GC. Sets of regions can be Eden, survivor, and/or old generation. CSets have a less than 1% impact on the size of the JVM.

​ CSets 将在GC中收集的区域集。在GC过程中,CSet中的所有实时数据都被清空(复制/移动)。区域集可以是Eden, survivor, and/or old generation。CSets 对JVM大小的影响小于1%。

3.3 Recommended Use Cases for G1(推荐G1使用的应用场景)

​ The first focus of G1 is to provide a solution for users running applications that require large heaps with limited GC latency. This means heap sizes of around 6GB or larger, and stable and predictable pause time below 0.5 seconds.

​ G1的第一个重点是为运行需要大量GC延迟的应用程序的用户提供解决方案。这意味着堆大小约为6GB或更大,并且稳定且可预测的暂停时间低于0.5秒。

​ Applications running today with either the CMS or the ParallelOldGC garbage collector would benefit switching to G1 if the application has one or more of the following traits.

​ 如果应用程序具有以下一个或多个特性,那么使用CMS或Parallel Old GC垃圾收集器运行的应用程序将有利于切换到G1。

  • Full GC durations are too long or too frequent.

    完整的GC持续时间太长或太频繁。

  • The rate of object allocation rate or promotion varies significantly.

    对象分配率或晋升率比较大。

  • Undesired long garbage collection or compaction pauses (longer than 0.5 to 1 second)

    垃圾收集或压缩暂停时间过长(超过0.5到1秒)

Note: If you are using CMS or ParallelOldGC and your application is not experiencing long garbage collection pauses, it is fine to stay with your current collector. Changing to the G1 collector is not a requirement for using the latest JDK.

​ 如果您使用的是CMS或Parallel Old GC,并且您的应用程序没有遇到长时间的垃圾收集暂停,那么可以使用当前收集器。使用最新的JDK不需要更改为G1收集器。

4. Reviewing GC with the CMS 回顾CMS

4.1 Reviewing Generational GC and CMS 回顾世代GC和CMS

​ The Concurrent Mark Sweep (CMS) collector (also referred to as the concurrent low pause collector) collects the tenured generation. It attempts to minimize the pauses due to garbage collection by doing most of the garbage collection work concurrently with the application threads. Normally the concurrent low pause collector does not copy or compact the live objects. A garbage collection is done without moving the live objects. If fragmentation becomes a problem, allocate a larger heap.

​ 并发标记清除(CMS)收集器(也称为并发低延迟收集器)收集终身生成。**它尝试通过与应用程序线程同时执行大多数垃圾收集工作来最小化由于垃圾收集而导致的暂停。**通常,并发低延迟收集器不会复制或压缩存活对象。垃圾收集是在不移动活动对象的情况下完成的。如果碎片化成为一个问题,请分配一个更大的堆。

Note: CMS collector on young generation uses the same algorithm as that of the parallel collector.

Note:年轻代的CMS收集器使用与并行收集器相同的算法。

4.2 CMS Collection Phases

The CMS collector performs the following phases on the old generation of the heap:

CMS收集器对老年代堆执行以下阶段:

4.2Reviewing Garbage Collection Steps

​ Next, let’s review CMS Collector operations step by step.

4.2.1 Heap Structure for CMS Collector CMS收集器的堆结构

The heap is split into three spaces. 堆被分成三个空间。
在这里插入图片描述
​ Young generation is split into Eden and two survivor spaces. Old generation is one contiguous space. Object collection is done in place. No compaction is done unless there is a full GC.

​ 年轻代被分成Eden and two survivor spaces。老年代是一个连续的空间。对象收集就地完成。除非有Full GC,否则不会进行压缩。

4.2.2 How Young GC works in CMS 年轻代中的GC如何在CMS中工作

​ The young generation is colored light green and the old generation in blue. This is what the CMS might look like if your application has been running for a while. Objects are scattered around the old generation area.

​ 年轻代是浅绿色的,老年代是蓝色的。如果您的应用程序已经运行了一段时间,CMS可能就是这样的。老年代地区到处都是物体。
在这里插入图片描述
​ With CMS, old generation objects are deallocated in place. They are not moved around. The space is not compacted unless there is a full GC.

​ 使用CMS,老年代对象将就地释放。它们不会被移动。除非有Full GC,否则空间不会被压缩。

4.2.3 Young Generation Collection

​ Live objects are copied from the Eden space and survivor space to the other survivor space. Any older objects that have reached their aging threshold are promoted to old generation.

​ 存活的对象从Eden 空间和survivor 空间复制到其他survivor 空间。任何已达到老化阈值的旧对象都将升级为老年代。
在这里插入图片描述

4.2.4 After Young GC

​ After a young GC, the Eden space is cleared and one of the survivor spaces is cleared.
在这里插入图片描述
​ Newly promoted objects are shown in dark blue on the diagram. The green objects are surviving young generation objects that have not yet been promoted to old generation.

​ 新晋升的对象在图表上以深蓝色显示。绿色对象是还没有被晋升到老年代的年轻代对象。

4.2.5 Old Generation Collection with CMS

​ Two stop the world events take place: initial mark and remark. When the old generation reaches a certain occupancy rate, the CMS is kicked off.
​ 两个stop the world 事件发生:最初的标记和remark。当老年代达到一定的占有率时,CMS就启动了。
在这里插入图片描述
​ (1) Initial mark is a short pause phase where live (reachable) objects are marked. (2) Concurrent marking finds live objects while the application continues to execute. Finally, in the (3) remark phase, objects are found that were missed during (2) concurrent marking in the previous phase.

​ (1) 初始标记是一个短暂的暂停阶段,其中存活(可到达)对象被标记。(2) 并发标记在应用程序继续执行时查找存活对象。最后,在(3)标记阶段,重新寻找在(2)前一阶段的并发标记中未标记的对象。

4.2.6 Old Generation Collection - Concurrent Sweep

​ Objects that were not marked in the previous phase are deallocated in place. There is no compaction.

​ 在前一阶段中未标记的对象将就地释放。没有压缩。
在这里插入图片描述
Note: Unmarked objects == Dead Objects

4.2.7 Old Generation Collection - After Sweeping

​ After the (4) Sweeping phase, you can see that a lot of memory has been freed up. You will also notice that no compaction has been done.

​ 在(4)清除阶段之后,您可以看到许多内存已被释放。您还将注意到没有进行压缩。
在这里插入图片描述
​ Finally, the CMS collector will move through the (5) resetting phase and wait for the next time the GC threshold is reached.

​ 最后,CMS收集器将通过(5)重置阶段,并等待下一次达到GC阈值。

5. The G1 Garbage Collector Step by Step

5.1 The G1 Garbage Collector Step by Step

​ The G1 collector takes a different approach to allocating the heap. The pictures that follow review the G1 system step by step.

​ G1收集器采用不同的方法来分配堆。接下来的图片将逐步回顾G1系统。

1: G1 Heap Structure

​ The heap is one memory area split into many fixed sized regions.

​ Region size is chosen by the JVM at startup. The JVM generally targets around 2000 regions varying in size from 1 to 32Mb.

​ 堆是一个内存区域,分成许多固定大小的区域。

​ 区域大小由JVM在启动时选择。JVM通常针对2000个大小从1到32Mb不等的区域。
在这里插入图片描述

2: G1 Heap Allocation

​ In reality, these regions are mapped into logical representations of Eden, Survivor, and old generation spaces.

​ 实际上,这些区域被映射到了 Eden, Survivor, and old空间的逻辑空间中。
在这里插入图片描述
​ The colors in the picture shows which region is associated with which role. Live objects are evacuated (i.e., copied or moved) from one region to another. Regions are designed to be collected in parallel with or without stopping all other application threads.

​ 图片中的颜色显示哪个区域与哪个角色关联。存活对象从一个区域转移到另一个区域(即复制或移动)。区域被设计为并行或不停止所有其他应用程序线程并行收集。

​ As shown regions can be allocated into Eden, survivor, and old generation regions. In addition, there is a fourth type of object known as Humongous regions. These regions are designed to hold objects that are 50% the size of a standard region or larger. They are stored as a set of contiguous regions. Finally the last type of regions would be the unused areas of the heap.

​ 如图所示,区域可以分配到 Eden, survivor, and old 区域。此外,还有第四种类型的物体称为巨区。这些区域设计用于容纳大小为标准区域50%或更大的对象。它们存储为一组相邻区域。最后一种类型的区域是堆中未使用的区域。

Note: At the time of this writing, collecting humongous objects has not been optimized. Therefore, you should avoid creating objects of this size.

​ 在撰写本文时,尚未对收集大量对象进行优化。因此,应避免创建此大小的对象。

3: Young Generation in G1

​ The heap is split into approximately 2000 regions. Minimum size is 1Mb and maximum size is 32Mb. Blue regions hold old generation objects and green regions hold young generation objects.

​ 堆被分成大约2000个区域。最小尺寸为1MB,最大尺寸为32 MB。蓝色区域包含老年代对象,绿色区域包含新生代对象。
在这里插入图片描述
Note that the regions are not required to be contiguous like the older garbage collectors.

注意,这些区域不需要像旧的垃圾收集器那样是连续的。

4: A Young GC in G1

​ Live objects are evacuated (i.e., copied or moved) to one or more survivor regions. If the aging threshold is met, some of the objects are promoted to old generation regions.

​ 存活的对象被转移(即复制或移动)到一个或多个survivor区域。如果满足老化阈值,则某些对象将晋升到老年代区域。
在这里插入图片描述
​ This is a stop the world (STW) pause. Eden size and survivor size is calculated for the next young GC. Accounting information is kept to help calculate the size. Things like the pause time goal are taken into consideration.

​ 这是一个STW暂停。计算下一个新生代GC的Eden大小和survivor大小。保留记录信息有助于计算规模。像暂停时间目标这样的事情都被考虑进去了。

​ This approach makes it very easy to resize regions, making them bigger or smaller as needed.

​ 这种方法可以很容易地调整区域大小,使它们根据需要变大或变小。

5: End of a Young GC with G1

​ Live objects have been evacuated to survivor regions or to old generation regions.

​ 存活的对象被移动到survivor区域或老年代区域。
在这里插入图片描述

Recently promoted objects are shown in dark blue. Survivor regions in green.

新晋升的对象显示为深蓝色。绿色的Survivor区域。

In summary, the following can be said about the young generation in G1:

综上所述,对于G1的新生代,可以说:

  • The heap is a single memory space split into regions.

  • Young generation memory is composed of a set of non-contiguous regions. This makes it easy to resize when needed.

  • Young generation garbage collections, or young GCs, are stop the world events. All application threads are stopped for the operation.

  • The young GC is done in parallel using multiple threads.

  • Live objects are copied to new survivor or old generation regions.

    堆是一个分成多个区域的内存空间。

    新生代的内存是由一组不连续的区域组成的。这使得在需要时调整大小变得容易。

    新生代的垃圾收集,或新生代的GCs,是stop the world的事件。所有应用程序线程都将为该操作停止。

    新生代的GC使用多个线程并行完成。

    存活对象被复制到新的survivor 或 old 区域。

5.2 Old Generation Collection with G1

​ Like the CMS collector, the G1 collector is designed to be a low pause collector for old generation objects. The following table describes the G1 collection phases on old generation.

​ 与CMS收集器一样,G1收集器被设计为用于老年代对象的低暂停收集器。下表描述了老年代的G1收集阶段。

5.2.1 G1 Collection Phases - Concurrent Marking Cycle Phases

​ The G1 collector performs the following phases on the old generation of the heap. Note that some phases are part of a young generation collection.

​ G1收集器在老年代堆上执行以下阶段。注意,有些阶段也是新生代收集器的一部分。

Phase Description
(1) Initial Mark *(Stop the World Event)*初始标记 This is a stop the world event. With G1, it is piggybacked on a normal young GC. Mark survivor regions (root regions) which may have references to objects in old generation.这是一个stop the world 事件。对于G1,它是由一个正常的年轻代GC携带的。标记survivor区域(根区域),这些区域可以引用老年代中的对象。
(2) Root Region Scanning根分区扫描 Scan survivor regions for references into the old generation. This happens while the application continues to run. The phase must be completed before a young GC can occur.扫描survivor区域,寻找到老年代的参考。当应用程序继续运行时会发生这种情况。必须先完成此阶段,然后才能发生新的GC。
(3) Concurrent Marking并发标记 Find live objects over the entire heap. This happens while the application is running. This phase can be interrupted by young generation garbage collections.在整个堆中查找存活对象。这是在应用程序运行时发生的。这个阶段可以被新生代的垃圾收集所中断。
(4) Remark *(Stop the World Event)*重新标记 Completes the marking of live object in the heap. Uses an algorithm called snapshot-at-the-beginning (SATB) which is much faster than what was used in the CMS collector.完成堆中存活对象的标记。使用一种称为“开始时快照”(SATB)的算法,该算法比CMS收集器中使用的算法快得多。
(5) Cleanup *(Stop the World Event and Concurrent)*清除 Performs accounting on live objects and completely free regions. (Stop the world)Scrubs the Remembered Sets. (Stop the world)Reset the empty regions and return them to the free list. (Concurrent) 对存活对象和完全自由区域执行标记。(Stop the world)清除RSets。(Stop the world)重置空区域并将其返回到空闲列表。(并发)
(*) Copying *(Stop the World Event)*复制 These are the stop the world pauses to evacuate or copy live objects to new unused regions. This can be done with young generation regions which are logged as [GC pause (young)]. Or both young and old generation regions which are logged as [GC Pause (mixed)]. 这些是“stop the world”以将活动对象转移或复制到新的未使用区域。这可以通过记录为“[GC pause(young)”的老年代区域来完成。或者记录为“[GC Pause(mixed)””的新生代和老年代区域。
5.2.2 G1 Old Generation Collection Step by Step

​ With the phases defined, let’s look at how they interact with the old generation in the G1 collector.

​ 在定义了阶段之后,让我们看看它们如何与G1收集器中的老年代交互。

6. Initial Marking Phase

​ Initial marking of live object is piggybacked on a young generation garbage collection. In the logs this is noted as GC pause (young)(inital-mark).

​ 存活对象的初始标记依赖于年轻代的垃圾收集(就是首先标记在老年代中有哪些对象是直接被新生代对象引用的)。在日志中,这被称为“GC pause(young)(inital mark)”。
在这里插入图片描述

7. Concurrent Marking Phase

​ If empty regions are found (as denoted by the “X”), they are removed immediately in the Remark phase. Also, “accounting” information that determines liveness is calculated.

​ 如果发现空白区域(如“X”所示),则在标记阶段立即将其删除。此外,还计算确定出存活的“accounting”信息。
在这里插入图片描述

8. Remark Phase

​ Empty regions are removed and reclaimed. Region liveness is now calculated for all regions.

​ 将移除并回收空区域。现在计算所有区域的区域存活性。
在这里插入图片描述

9. Copying/Cleanup Phase

​ G1 selects the regions with the lowest “liveness”, those regions which can be collected the fastest. Then those regions are collected at the same time as a young GC. This is denoted in the logs as [GC pause (mixed)]. So both young and old generations are collected at the same time.

​ G1选择“存活”最低的区域,即可以最快被收集的区域。然后这些区域与年轻的GC同时被收集。这在日志中表示为[GC pause(mixed)]。所以,这种情况下新生代和老年代是同时被收集的。
在这里插入图片描述

10. After Copying/Cleanup Phase

​ The regions selected have been collected and compacted into the dark blue region and the dark green region shown in the diagram.

​ 选定的区域已收集并压缩为图中所示的深蓝色区域和深绿色区域。
在这里插入图片描述

5.2.3 Summary of Old Generation GC

​ In summary, there are a few key points we can make about the G1 garbage collection on the old generation.

​ 总结,关于老年代上的G1垃圾收集,我们可以提出一些要点。

  • Concurrent Marking Phase:

    • Liveness information is calculated concurrently while the application is running.

    • This liveness information identifies which regions will be best to reclaim during an evacuation pause.

    • There is no sweeping phase like in CMS.

      当应用程序运行时,同时计算存活信息。

      该存活信息确定了在暂停期间最应该被回收的区域。

      没有像CMS那样的清除阶段。

  • Remark Phase:

    • Uses the Snapshot-at-the-Beginning (SATB) algorithm which is much faster then what was used with CMS.

      使用快照开始(SATB)算法,比CMS使用的速度快得多。

    • Completely empty regions are reclaimed.

      完全空的区域被回收。

  • Copying/Cleanup Phase:

    • Young generation and old generation are reclaimed at the same time.

      新生代和老年代同时被回收。

    • Old generation regions are selected based on their liveness.

      老年代区域是基于他们的存活性选择的。

6. Command Line Options and Best Practices

6.1 Command Line Options and Best Practices

In this section let’s take a look at the various command line options for G1.

6.1.1 Basic Command Line

​ To enable the G1 Collector use: -XX:+UseG1GC

​ Here is a sample command line for starting the Java2Demo included in the JDK demos and samples download:
​ **java -Xmx50m -Xms50m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -jar **

c:\javademos\demo\jfc\Java2D\Java2demo.jar

6.1.2 Key Command Line Switches
  • -XX:+UseG1GC:

    ​ Tells the JVM to use the G1 Garbage collector.

  • -XX:MaxGCPauseMillis=200:

    ​ Sets a target for the maximum GC pause time. This is a soft goal, and the JVM will make its best effort to achieve it. Therefore, the pause time goal will sometimes not be met. The default value is 200 milliseconds.

  • -XX:InitiatingHeapOccupancyPercent=45:

    ​ Percentage of the (entire) heap occupancy to start a concurrent GC cycle. It is used by G1 to trigger a concurrent GC cycle based on the occupancy of the entire heap, not just one of the generations. A value of 0 denotes ‘do constant GC cycles’. The default value is 45 (i.e., 45% full or occupied).

6.1.3 Best Practices

There are a few best practices you should follow when using G1.

Do not Set Young Generation Size

Explicitly setting young generation size via -Xmn meddles with the default behavior of the G1 collector.

  • G1 will no longer respect the pause time target for collections. So in essence, setting the young generation size disables the pause time goal.
  • G1 is no longer able to expand and contract the young generation space as needed. Since the size is fixed, no changes can be made to the size.

Response Time Metrics

​ Instead of using average response time (ART) as a metric to set the XX:MaxGCPauseMillis=<N>, consider setting value that will meet the goal 90% of the time or more. This means 90% of users making a request will not experience a response time higher than the goal. Remember, the pause time is a goal and is not guaranteed to always be met.

What is an Evacuation Failure?

​ A promotion failure that happens when a JVM runs out of heap regions during the GC for either survivors and promoted objects. The heap can’t expand because it is already at max. This is indicated in the GC logs when using -XX:+PrintGCDetails by to-space overflow. This is expensive!

  • GC still has to continue so space has to be freed up.
  • Unsuccessfully copied objects have to be tenured in place.
  • Any updates to RSets of regions in the CSet have to be regenerated.
  • All of these steps are expensive.

How to avoid Evacuation Failure

​ To avoid evacuation failure, consider the following options.

  • Increase heap size
    • Increase the -XX:G1ReservePercent=n, the default is 10.
    • G1 creates a false ceiling by trying to leave the reserve memory free in case more ‘to-space’ is desired.
  • Start the marking cycle earlier
  • Increase the number of marking threads using the -XX:ConcGCThreads=n option.

Complete List of G1 GC Switches

​ This is the complete list of G1 GC switches. Remember to use the best practices outlined above.

Option and Default Value Description
-XX:+UseG1GC Use the Garbage First (G1) Collector
-XX:MaxGCPauseMillis=n Sets a target for the maximum GC pause time. This is a soft goal, and the JVM will make its best effort to achieve it.
-XX:InitiatingHeapOccupancyPercent=n Percentage of the (entire) heap occupancy to start a concurrent GC cycle. It is used by GCs that trigger a concurrent GC cycle based on the occupancy of the entire heap, not just one of the generations (e.g., G1). A value of 0 denotes ‘do constant GC cycles’. The default value is 45.
-XX:NewRatio=n Ratio of new/old generation sizes. The default value is 2.
-XX:SurvivorRatio=n Ratio of eden/survivor space size. The default value is 8.
-XX:MaxTenuringThreshold=n Maximum value for tenuring threshold. The default value is 15.
-XX:ParallelGCThreads=n Sets the number of threads used during parallel phases of the garbage collectors. The default value varies with the platform on which the JVM is running.
-XX:ConcGCThreads=n Number of threads concurrent garbage collectors will use. The default value varies with the platform on which the JVM is running.
-XX:G1ReservePercent=n Sets the amount of heap that is reserved as a false ceiling to reduce the possibility of promotion failure. The default value is 10.
-XX:G1HeapRegionSize=n With G1 the Java heap is subdivided into uniformly sized regions. This sets the size of the individual sub-divisions. The default value of this parameter is determined ergonomically based upon heap size. The minimum value is 1Mb and the maximum value is 32Mb.
查看全文
如若内容造成侵权/违法违规/事实不符,请联系编程学习网邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

相关文章

  1. 数据压缩第九次作业:JPEG原理分析及JPEG解码器的调试

    实验目的: 掌握JPEG编解码系统的基本原理。初步掌握复杂的数据压缩算法实现,并能根据理论分析需要实现所对应数据的输出。 主要设备: 安装Windows和Visual Studio软件的个人计算机 实验内容: 一、JPEG: 1.基本定义: JPEG(Joint Photographic Experts Group)是JPEG标准的…...

    2024/4/24 8:11:55
  2. JLing家庭管家(基于Agora技术实现)

    JLing JLing是一个可以工作在Linux的自定义中文语音对话机器人 (csdn :https://blog.csdn.net/weixin_40490238) (github: https://github.com/Kingzhoudk/JLing) 基于Agora技术对JLing的改造,成功实现了视频聊天、智能家居的远程控制、监控等功能。 视频链接: bilibili 整体…...

    2024/4/24 8:11:54
  3. Spring + Hibernate多租户配置

    介绍 多租户(Multi-tenancy)是一种软件架构,一个服务实例可以服务多个客户,每个客户叫一个租户。而这其中最关键的一部分就是各个租户的数据的分离。 针对这种情形,主要有三种策略,数据的隔离级别从高到低依次是:Database per Tenant, Shared Database, Separate Schema, …...

    2024/4/24 8:11:53
  4. 玩转Docker----- 第三部-----------docker公有、私有仓库的搭建

    玩转Docker----- 第三部-----------docker公有、私有仓库的搭建 1.Docker 仓库 Docker仓库是用来包含镜像的位置,Docker提供一个注册服务器 (Register)来保存多个仓库,每个仓库又可以包含多个具备不同tag的镜像。 Docker运行中使用的默认仓库是Docker Hub公共仓库。 仓库的出…...

    2024/4/24 8:11:59
  5. ES6标准入门

    文章目录一、什么是ES6?二、为什么使用ES6?三、ES6语法特性3.1 新的声明方法3.2 let 命令3.3 const 命令四、 解构赋值4.1 数组模型的解构(Array)4.1.1 基本4.1.2 可嵌套4.1.3 可忽略4.1.4 不完全解构4.1.5 剩余运算符4.1.6 字符串等4.2 对象模型的解构(Object)4.2.1 基…...

    2024/4/24 8:11:51
  6. Python基础语法_小结

    Python基础语法_小结1 Python语言介绍&安装配置1.1 Python数据相关应用1.2 Python特点1.3 生成配置文件,修改默认路径2 Python基础语法2.1 关键字(即保留字)2.2 输入和输出2.3 声明变量2.4 自增运算3 标准数据类型3.1 布尔值bool3.1.1 布尔值的运算符3.2 数字numbers…...

    2024/4/20 9:53:20
  7. python零基础学习之os模块的学习

    OS模块的学习 1.os.name 如果结果为nt, 则为windows系统, 如果结果为posix, 则为unix系统 当存在跨系统的时候则可以用这个做一个判断比如: if os.name == "nt":cmd = "ipconfig" elif os.name == "posix": cmd = "ifconfig"os.sy…...

    2024/4/16 16:27:38
  8. Java编程思想 第四版全部习题答案

    http://greggordon.org/java/tij4/solutions.htm...

    2024/5/3 20:47:13
  9. LeetCode-1132. 报告的记录 II (中等)

    题目来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/reported-posts-ii 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 本人思路: 1、将actions表与removals表根据条件a.post_id = r.post_id左连接 ,并且筛选出 extra = spam’行 …...

    2024/5/3 15:15:15
  10. java—单例模式实现方式

    1.饿汉式(线程安全,调用效率高,但是不能延时加载):JVM初始化的时候创建对象,不能延时public class ImageLoader{ private static ImageLoader instance = new ImageLoader; private ImageLoader(){} public static ImageLoader getInstance(){ return instance; } }2.懒…...

    2024/4/16 16:27:48
  11. java学习基础知识之认识-静态修饰符static

    1:静态修饰符static 可修饰1.变量—2.方法–3.代码块! —————————————————————————————————— a:修饰变量:静态变量! —————————————————————————————————— class B{ //int i=1; 此处i位成员变量:属…...

    2024/5/3 12:32:59
  12. GD32F407之硬件IIC(从机模式)

    承接上一篇GD32F407硬件IIC主机模式,下面这一片介绍GD32F407硬件IIC从机模式,用MCU来做从机模式百度上有用的资源比较少,都是STM32里面的源码,千篇一律,有点水帖的感觉。网上百度用GPIO模拟方式来做从机好像没有找到资料,也咨询了GD32F407的FE没有做过GPIO模拟从机,所以…...

    2024/4/15 6:53:31
  13. Linux chgrp 命令

    命令详解 Linux chgrp命令用于变更文件或目录的所属群组。 在UNIX系统家族里,文件或目录权限的掌控以拥有者及所属群组来管理。您可以使用chgrp指令去变更文件与目录的所属群组,设置方式采用群组名称或群组识别码皆可。 命令全拼 chgrp = change group 语法格式chgrp [-cfhRv…...

    2024/4/18 13:47:49
  14. HiveSQL优化技巧

    技巧1:用group by替换distinct。 原有写法: SELECT distinct user_name FROM user_trade WHERE dt>0;优化写法: SELECT user_name FROM user_trade WHERE dt>0 GROUP BY user_name;使用group by可以看到运行时间减少许多。 注意:在极大的数据量(较多重复值)时,可以…...

    2024/4/24 8:11:50
  15. 街景编码字符识别系列(三)

    街景编码字符识别系列(三)1.CNN介绍2.CNN发展 1.CNN介绍 卷积神经网络(简称CNN)是一类特殊的人工神经网络,是深度学习中重要的一个分支。CNN在很多领域都表现优异,精度和速度比传统计算学习算法高很多。特别是在计算机视觉领域,CNN是解决图像分类、图像检索、物体检测和…...

    2024/5/3 12:01:52
  16. TCP协议

    TCP协议解读 一、TCP头部解析:0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Source Port | …...

    2024/4/24 8:11:50
  17. MQ2和MQ7电压值与PPM的转换公式

    最近给人做了个机智云的环境监测程序,第一次赚外快,100块钱我就接了。写程序的时候发现好多人在找这两传感器电压值和PPM的转换,我这个也是照搬别人的公式,不过效果还不错。不过遗憾的是,我都写的差不多了,他又要让我换ONENET,ONENET我不太熟,他就又给了我100让我帮他搞…...

    2024/4/29 14:44:23
  18. 如果类A和类B是从同一个基类N派生的,且类D是类A和类B的多重继承派生类,要求在程序中通过类A和类B的构造函数去调用基类N的构造函数,分别对类A和类B的数据成员a初始化。

    如果类A和类B是从同一个基类N派生的,且类D是类A和类B的多重继承派生类,要求在程序中通过类A和类B的构造函数去调用基类N的构造函数,分别对类A和类B的数据成员a初始化。 #include<iostream> using namespace std;class N {public:N(int aN){a=aN;}int a;void display()…...

    2024/5/1 1:48:13
  19. 二、java万物皆可盘之用引用操纵对象

    用引用操纵对象 雷迪森and砖头们,让我们来说下引用和对象有啥区别? 在前面的文章中简单概括了对象(某个将数据和功能封装到一块的实例),下面我们举个简单的例子:把“人”作为一个类型,实例化出一个具体的名叫李小明的人,这个人是一个对象。引用就是给这个实例化出的人起…...

    2024/4/24 8:11:52
  20. Win10中安装Docker并运行Windows Server Core2019

    1、官网下载并安装,非常easy https://store.docker.com/editions/community/docker-ce-desktop-windows2、建议使用阿里的“镜像加速器”服务,否则会比较慢,找到加速器地址3、打开docker程序,将地址配置到中红框位置,并点击“Apply & Restart”4、在cmd中执行如下命令…...

    2024/4/24 8:11:53

最新文章

  1. WRT1900ACS搭建openwrt服务器小记

    参考链接 wrt1900acs openwrt wrt1900acs openwrt 刷机 wrt1900acs原生固件刷openwrt-23.05.3-mvebu-cortexa9-linksys_wrt1900acs-squashfs-factory.img wrt1900acs openwrt更新刷openwrt-23.05.3-mvebu-cortexa9-linksys_wrt1900acs-squashfs-sysupgrade.bin 通过WEB UI来…...

    2024/5/8 12:11:41
  2. 梯度消失和梯度爆炸的一些处理方法

    在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言&#xff0c;在此感激不尽。 权重和梯度的更新公式如下&#xff1a; w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...

    2024/5/7 10:36:02
  3. 布隆过滤器是如何避免缓存穿透的?

    布隆过滤器&#xff08;Bloom filter&#xff09;是一种空间效率极高的概率型数据结构&#xff0c;用于判断一个元素是否在一个集合中。它的原理是当一个元素被加入集合时&#xff0c;通过几个不同的Hash函数将元素映射成一个位数组中的多个位置&#xff0c;再次查询时如果位数…...

    2024/5/4 6:23:37
  4. 零基础 HTML 入门(详细)

    目录 1.简介 1.1 HTML是什么? 1.2 HTML 版本 1.3 通用声明 2.HTML 编辑器 3.标签的语法 4.HTML属性 5.常用标签 5.1 head 元素 5.1.1 title 标签 5.1.2 base 标签 5.1.3 link 标签 5.1.4 style 标签 5.1.5 meta 标签 5.1.6 script 5.2 HTML 注释 5.3 段落标签…...

    2024/5/5 8:40:44
  5. STL--vector有哪些应用场景

    vector 在 C 中是一种非常灵活和强大的容器&#xff0c;适用于多种不同的应用场景。以下是一些常见的应用场景&#xff1a; 1 动态数据集合&#xff1a;当你不确定数据集的大小&#xff0c;或者数据集的大小会随时间变化时&#xff0c;vector 是理想的选择。例如&#xff0c;在…...

    2024/5/7 5:20:54
  6. 【外汇早评】美通胀数据走低,美元调整

    原标题:【外汇早评】美通胀数据走低,美元调整昨日美国方面公布了新一期的核心PCE物价指数数据,同比增长1.6%,低于前值和预期值的1.7%,距离美联储的通胀目标2%继续走低,通胀压力较低,且此前美国一季度GDP初值中的消费部分下滑明显,因此市场对美联储后续更可能降息的政策…...

    2024/5/8 6:01:22
  7. 【原油贵金属周评】原油多头拥挤,价格调整

    原标题:【原油贵金属周评】原油多头拥挤,价格调整本周国际劳动节,我们喜迎四天假期,但是整个金融市场确实流动性充沛,大事频发,各个商品波动剧烈。美国方面,在本周四凌晨公布5月份的利率决议和新闻发布会,维持联邦基金利率在2.25%-2.50%不变,符合市场预期。同时美联储…...

    2024/5/7 9:45:25
  8. 【外汇周评】靓丽非农不及疲软通胀影响

    原标题:【外汇周评】靓丽非农不及疲软通胀影响在刚结束的周五,美国方面公布了新一期的非农就业数据,大幅好于前值和预期,新增就业重新回到20万以上。具体数据: 美国4月非农就业人口变动 26.3万人,预期 19万人,前值 19.6万人。 美国4月失业率 3.6%,预期 3.8%,前值 3…...

    2024/5/4 23:54:56
  9. 【原油贵金属早评】库存继续增加,油价收跌

    原标题:【原油贵金属早评】库存继续增加,油价收跌周三清晨公布美国当周API原油库存数据,上周原油库存增加281万桶至4.692亿桶,增幅超过预期的74.4万桶。且有消息人士称,沙特阿美据悉将于6月向亚洲炼油厂额外出售更多原油,印度炼油商预计将每日获得至多20万桶的额外原油供…...

    2024/5/7 14:25:14
  10. 【外汇早评】日本央行会议纪要不改日元强势

    原标题:【外汇早评】日本央行会议纪要不改日元强势近两日日元大幅走强与近期市场风险情绪上升,避险资金回流日元有关,也与前一段时间的美日贸易谈判给日本缓冲期,日本方面对汇率问题也避免继续贬值有关。虽然今日早间日本央行公布的利率会议纪要仍然是支持宽松政策,但这符…...

    2024/5/4 23:54:56
  11. 【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响

    原标题:【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响近日伊朗局势升温,导致市场担忧影响原油供给,油价试图反弹。此时OPEC表态稳定市场。据消息人士透露,沙特6月石油出口料将低于700万桶/日,沙特已经收到石油消费国提出的6月份扩大出口的“适度要求”,沙特将满…...

    2024/5/4 23:55:05
  12. 【外汇早评】美欲与伊朗重谈协议

    原标题:【外汇早评】美欲与伊朗重谈协议美国对伊朗的制裁遭到伊朗的抗议,昨日伊朗方面提出将部分退出伊核协议。而此行为又遭到欧洲方面对伊朗的谴责和警告,伊朗外长昨日回应称,欧洲国家履行它们的义务,伊核协议就能保证存续。据传闻伊朗的导弹已经对准了以色列和美国的航…...

    2024/5/4 23:54:56
  13. 【原油贵金属早评】波动率飙升,市场情绪动荡

    原标题:【原油贵金属早评】波动率飙升,市场情绪动荡因中美贸易谈判不安情绪影响,金融市场各资产品种出现明显的波动。随着美国与中方开启第十一轮谈判之际,美国按照既定计划向中国2000亿商品征收25%的关税,市场情绪有所平复,已经开始接受这一事实。虽然波动率-恐慌指数VI…...

    2024/5/7 11:36:39
  14. 【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试

    原标题:【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试美国和伊朗的局势继续升温,市场风险情绪上升,避险黄金有向上突破阻力的迹象。原油方面稍显平稳,近期美国和OPEC加大供给及市场需求回落的影响,伊朗局势并未推升油价走强。近期中美贸易谈判摩擦再度升级,美国对中…...

    2024/5/4 23:54:56
  15. 【原油贵金属早评】市场情绪继续恶化,黄金上破

    原标题:【原油贵金属早评】市场情绪继续恶化,黄金上破周初中国针对于美国加征关税的进行的反制措施引发市场情绪的大幅波动,人民币汇率出现大幅的贬值动能,金融市场受到非常明显的冲击。尤其是波动率起来之后,对于股市的表现尤其不安。隔夜美国股市出现明显的下行走势,这…...

    2024/5/6 1:40:42
  16. 【外汇早评】美伊僵持,风险情绪继续升温

    原标题:【外汇早评】美伊僵持,风险情绪继续升温昨日沙特两艘油轮再次发生爆炸事件,导致波斯湾局势进一步恶化,市场担忧美伊可能会出现摩擦生火,避险品种获得支撑,黄金和日元大幅走强。美指受中美贸易问题影响而在低位震荡。继5月12日,四艘商船在阿联酋领海附近的阿曼湾、…...

    2024/5/4 23:54:56
  17. 【原油贵金属早评】贸易冲突导致需求低迷,油价弱势

    原标题:【原油贵金属早评】贸易冲突导致需求低迷,油价弱势近日虽然伊朗局势升温,中东地区几起油船被袭击事件影响,但油价并未走高,而是出于调整结构中。由于市场预期局势失控的可能性较低,而中美贸易问题导致的全球经济衰退风险更大,需求会持续低迷,因此油价调整压力较…...

    2024/5/4 23:55:17
  18. 氧生福地 玩美北湖(上)——为时光守候两千年

    原标题:氧生福地 玩美北湖(上)——为时光守候两千年一次说走就走的旅行,只有一张高铁票的距离~ 所以,湖南郴州,我来了~ 从广州南站出发,一个半小时就到达郴州西站了。在动车上,同时改票的南风兄和我居然被分到了一个车厢,所以一路非常愉快地聊了过来。 挺好,最起…...

    2024/5/7 9:26:26
  19. 氧生福地 玩美北湖(中)——永春梯田里的美与鲜

    原标题:氧生福地 玩美北湖(中)——永春梯田里的美与鲜一觉醒来,因为大家太爱“美”照,在柳毅山庄去寻找龙女而错过了早餐时间。近十点,向导坏坏还是带着饥肠辘辘的我们去吃郴州最富有盛名的“鱼头粉”。说这是“十二分推荐”,到郴州必吃的美食之一。 哇塞!那个味美香甜…...

    2024/5/4 23:54:56
  20. 氧生福地 玩美北湖(下)——奔跑吧骚年!

    原标题:氧生福地 玩美北湖(下)——奔跑吧骚年!让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 啊……啊……啊 两…...

    2024/5/4 23:55:06
  21. 扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!

    原标题:扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!扒开伪装医用面膜,翻六倍价格宰客!当行业里的某一品项火爆了,就会有很多商家蹭热度,装逼忽悠,最近火爆朋友圈的医用面膜,被沾上了污点,到底怎么回事呢? “比普通面膜安全、效果好!痘痘、痘印、敏感肌都能用…...

    2024/5/5 8:13:33
  22. 「发现」铁皮石斛仙草之神奇功效用于医用面膜

    原标题:「发现」铁皮石斛仙草之神奇功效用于医用面膜丽彦妆铁皮石斛医用面膜|石斛多糖无菌修护补水贴19大优势: 1、铁皮石斛:自唐宋以来,一直被列为皇室贡品,铁皮石斛生于海拔1600米的悬崖峭壁之上,繁殖力差,产量极低,所以古代仅供皇室、贵族享用 2、铁皮石斛自古民间…...

    2024/5/4 23:55:16
  23. 丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者

    原标题:丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者【公司简介】 广州华彬企业隶属香港华彬集团有限公司,专注美业21年,其旗下品牌: 「圣茵美」私密荷尔蒙抗衰,产后修复 「圣仪轩」私密荷尔蒙抗衰,产后修复 「花茵莳」私密荷尔蒙抗衰,产后修复 「丽彦妆」专注医学护…...

    2024/5/4 23:54:58
  24. 广州械字号面膜生产厂家OEM/ODM4项须知!

    原标题:广州械字号面膜生产厂家OEM/ODM4项须知!广州械字号面膜生产厂家OEM/ODM流程及注意事项解读: 械字号医用面膜,其实在我国并没有严格的定义,通常我们说的医美面膜指的应该是一种「医用敷料」,也就是说,医用面膜其实算作「医疗器械」的一种,又称「医用冷敷贴」。 …...

    2024/5/6 21:42:42
  25. 械字号医用眼膜缓解用眼过度到底有无作用?

    原标题:械字号医用眼膜缓解用眼过度到底有无作用?医用眼膜/械字号眼膜/医用冷敷眼贴 凝胶层为亲水高分子材料,含70%以上的水分。体表皮肤温度传导到本产品的凝胶层,热量被凝胶内水分子吸收,通过水分的蒸发带走大量的热量,可迅速地降低体表皮肤局部温度,减轻局部皮肤的灼…...

    2024/5/4 23:54:56
  26. 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...

    解析如下&#xff1a;1、长按电脑电源键直至关机&#xff0c;然后再按一次电源健重启电脑&#xff0c;按F8健进入安全模式2、安全模式下进入Windows系统桌面后&#xff0c;按住“winR”打开运行窗口&#xff0c;输入“services.msc”打开服务设置3、在服务界面&#xff0c;选中…...

    2022/11/19 21:17:18
  27. 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。

    %读入6幅图像&#xff08;每一幅图像的大小是564*564&#xff09; f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...

    2022/11/19 21:17:16
  28. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...

    win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面&#xff0c;在等待界面中我们需要等待操作结束才能关机&#xff0c;虽然这比较麻烦&#xff0c;但是对系统进行配置和升级…...

    2022/11/19 21:17:15
  29. 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...

    有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows&#xff0c;请勿关闭计算机”的提示&#xff0c;要过很久才能进入系统&#xff0c;有的用户甚至几个小时也无法进入&#xff0c;下面就教大家这个问题的解决方法。第一种方法&#xff1a;我们首先在左下角的“开始…...

    2022/11/19 21:17:14
  30. win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...

    置信有很多用户都跟小编一样遇到过这样的问题&#xff0c;电脑时发现开机屏幕显现“正在配置Windows Update&#xff0c;请勿关机”(如下图所示)&#xff0c;而且还需求等大约5分钟才干进入系统。这是怎样回事呢&#xff1f;一切都是正常操作的&#xff0c;为什么开时机呈现“正…...

    2022/11/19 21:17:13
  31. 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...

    Win7系统开机启动时总是出现“配置Windows请勿关机”的提示&#xff0c;没过几秒后电脑自动重启&#xff0c;每次开机都这样无法进入系统&#xff0c;此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一&#xff1a;开机按下F8&#xff0c;在出现的Windows高级启动选…...

    2022/11/19 21:17:12
  32. 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...

    有不少windows10系统用户反映说碰到这样一个情况&#xff0c;就是电脑提示正在准备windows请勿关闭计算机&#xff0c;碰到这样的问题该怎么解决呢&#xff0c;现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法&#xff1a;1、2、依次…...

    2022/11/19 21:17:11
  33. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...

    今天和大家分享一下win7系统重装了Win7旗舰版系统后&#xff0c;每次关机的时候桌面上都会显示一个“配置Windows Update的界面&#xff0c;提示请勿关闭计算机”&#xff0c;每次停留好几分钟才能正常关机&#xff0c;导致什么情况引起的呢&#xff1f;出现配置Windows Update…...

    2022/11/19 21:17:10
  34. 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...

    只能是等着&#xff0c;别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚&#xff0c;只能是考虑备份数据后重装系统了。解决来方案一&#xff1a;管理员运行cmd&#xff1a;net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...

    2022/11/19 21:17:09
  35. 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?

    原标题&#xff1a;电脑提示“配置Windows Update请勿关闭计算机”怎么办&#xff1f;win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢&#xff1f;一般的方…...

    2022/11/19 21:17:08
  36. 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...

    关机提示 windows7 正在配置windows 请勿关闭计算机 &#xff0c;然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;关机提示 windows7 正在配…...

    2022/11/19 21:17:05
  37. 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...

    钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...

    2022/11/19 21:17:05
  38. 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...

    前几天班里有位学生电脑(windows 7系统)出问题了&#xff0c;具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面&#xff0c;长时间没反应&#xff0c;无法进入系统。这个问题原来帮其他同学也解决过&#xff0c;网上搜了不少资料&#x…...

    2022/11/19 21:17:04
  39. 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...

    本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法&#xff0c;并在最后教给你1种保护系统安全的好方法&#xff0c;一起来看看&#xff01;电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中&#xff0c;添加了1个新功能在“磁…...

    2022/11/19 21:17:03
  40. 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...

    许多用户在长期不使用电脑的时候&#xff0c;开启电脑发现电脑显示&#xff1a;配置windows更新失败&#xff0c;正在还原更改&#xff0c;请勿关闭计算机。。.这要怎么办呢&#xff1f;下面小编就带着大家一起看看吧&#xff01;如果能够正常进入系统&#xff0c;建议您暂时移…...

    2022/11/19 21:17:02
  41. 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...

    配置windows update失败 还原更改 请勿关闭计算机&#xff0c;电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;配置windows update失败 还原更改 请勿关闭计算机&#x…...

    2022/11/19 21:17:01
  42. 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...

    不知道大家有没有遇到过这样的一个问题&#xff0c;就是我们的win7系统在关机的时候&#xff0c;总是喜欢显示“准备配置windows&#xff0c;请勿关机”这样的一个页面&#xff0c;没有什么大碍&#xff0c;但是如果一直等着的话就要两个小时甚至更久都关不了机&#xff0c;非常…...

    2022/11/19 21:17:00
  43. 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...

    当电脑出现正在准备配置windows请勿关闭计算机时&#xff0c;一般是您正对windows进行升级&#xff0c;但是这个要是长时间没有反应&#xff0c;我们不能再傻等下去了。可能是电脑出了别的问题了&#xff0c;来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...

    2022/11/19 21:16:59
  44. 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...

    我们使用电脑的过程中有时会遇到这种情况&#xff0c;当我们打开电脑之后&#xff0c;发现一直停留在一个界面&#xff1a;“配置Windows Update失败&#xff0c;还原更改请勿关闭计算机”&#xff0c;等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢&#xff0…...

    2022/11/19 21:16:58
  45. 如何在iPhone上关闭“请勿打扰”

    Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...

    2022/11/19 21:16:57