Fundamentals of Garbage Collection
【Fundamentals of Garbage Collection】
1、Reclaims objects that are no longer being used, clears their memory, and keeps the memory available for future allocations. Managed objects automatically get clean content to start with, so their constructors do not have to initialize every data field.
2、Visual memory can be in three states:
1)Free. The block of memory has no references to it and is available for allocation.
2)Reserved. The block of memory is available for your use and cannot be used for any other allocation request. However, you cannot store data to this memory block until it is committed.
3)Committed. The block of memory is assigned to physical storage.
3、Virtual address space can get fragmented. This means that there are free blocks, also known as holes, in the address space. When a virtual memory allocation is requested, the virtual memory manager has to find a single free block that is large enough to satisfy that allocation request. Even if you have 2 GB of free space, the allocation that requires 2 GB will be unsuccessful unless all of that space is in a single address block.
4、Conditions for a Garbage Collection.
Garbage collection occurs when one of the following conditions is true:
The system has low physical memory.(被动)
The memory that is used by allocated objects on the managed heap surpasses an acceptable threshold. This means that a threshold of acceptable memory usage has been exceeded on the managed heap. This threshold is continuously adjusted as the process runs.(被动)
The GC. Collect method is called. (主动)
5、When a garbage collection is triggered, the garbage collector reclaims the memory that is occupied by dead objects. The reclaiming process compacts live objects so that they are moved together, and the dead space is removed, thereby making the heap smaller. This ensures that objects that are allocated together stay together on the managed heap, to preserve their locality.
6、The heap can be considered as the accumulation of two heaps: the large object heap and the small object heap.
The large object heap contains objects that are 85,000 bytes and larger. Very large objects on the large object heap are usually arrays. It is rare for an instance object to be extremely large.
【Generations】
1、There are three generations of objects on the heap: 0、1、2。
2、Newly allocated objects form a new generation of objects and are implicitly generation 0 collections, unless they are large objects, in which case they go on the large object heap in a generation 2 collection.
3、每一次GC幸存下来的对象,会晋升到更高级的Generation。
4、Generation 0、1 也叫作 ephemeral generation。0、1必须在ephemeral segment中。ephemeral segment中可以有2.
5、The amount of freed memory from an ephemeral garbage collection is limited to the size of the ephemeral segment
【What Happens During a Garbage Collection】
Before a garbage collection starts, all managed threads are suspended except for the thread that triggered the garbage collection

When a finalizable object is discovered to be dead, its finalizer is put in a queue so that its cleanup actions are executed, but the object itself is promoted to the next generation. Therefore, you have to wait until the next garbage collection that occurs on that generation (which is not necessarily the next garbage collection) to determine whether the object has been reclaimed.
GC分为2种:Workstation、Server。Server类有专门的GC线程。

Workstation并发GC模型。此模型下,0、1同步完成,2在GC线程中完成。
Fundamentals of Garbage Collection的更多相关文章
- 从ASP.NET Core 3.0 preview 特性,了解CLR的Garbage Collection
前言 在阅读这篇文章:Announcing Net Core 3 Preview3的时候,我看到了这样一个特性: Docker and cgroup memory Limits We conclude ...
- Unity性能优化(3)-官方教程Optimizing garbage collection in Unity games翻译
本文是Unity官方教程,性能优化系列的第三篇<Optimizing garbage collection in Unity games>的翻译. 相关文章: Unity性能优化(1)-官 ...
- How Garbage Collection Really Works
Java Memory Management, with its built-in garbage collection, is one of the language's finest achiev ...
- Java Garbage Collection Basics--转载
原文地址:http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html Overview Purpose ...
- AutoReleasePool 和 ARC 以及Garbage Collection
AutoReleasePool autoreleasepool并不是总是被auto 创建,然后自动维护应用创建的对象. 自动创建的情况如下: 1. 使用NSThread的detachNewThread ...
- [翻译]Java垃圾收集精粹(Java Garbage Collection Distilled)
source URL: http://www.infoq.com/articles/Java_Garbage_Collection_Distilled Name: Java Garbage Colle ...
- The Impact of Garbage Collection on Application Performance
As we’ve seen, the performance of the garbage collector is not determined by the number of dead obje ...
- [Java] 垃圾回收 ( Garbage Collection ) 的步骤演示
关于 JVM 垃圾回收机制的基础内容,可参考上一篇博客 垃圾回收机制 ( Garbage Collection ) 简介 上一篇博客,介绍了堆的内存被分为三个部分:年轻代.老年代.永生代.这篇博文将演 ...
- [Java] 垃圾回收机制 ( Garbage Collection ) 简介
自动垃圾回收( Automatic Garbage Collection ) 自动垃圾回收,是指在堆(Heap)内存上分辨哪些对象还在被使用,哪些对象没有被使用,并清除没有被使用的对象.所以,这里的垃 ...
随机推荐
- ces
1. 测试目录 1.1. 测试目录 2. 测试目录2 2.1 测试目录
- Hibernate查询视图返回null问题说明及解决办法
在Hibernate中对含有主键的单表操作比较简单,直接使用Hibernate针对数据库表对象进行反向生成代码,直接调用就可以了.但是在实际项目当中,经常会用到不少的多表联合查询操作,网上有很多示例, ...
- Linux:root下的文件-anaconda-ks.cfg详解
anaconda-ks.cfg详解 系统安装的时候生成的一个文件,通过这个文件可以修改成自动安装的脚本,用于自动安装同样配置的系统. 自动生成的启动文件anaconda# Kickstart file ...
- Jenkins上War文件部署实战
War文件部署 1.jenkins需要安装Deploy Plugin插件:在[系统管理]-[插件管理]下,如果没有安装,则在可选插件下找到该插件,然后安装(如图是1.5版本安装好的截图) 2.在构建的 ...
- Servlet不是线程安全的。
要解释为什么Servlet为什么不是线程安全的,需要了解Servlet容器(即Tomcat)使如何响应HTTP请求的. 当Tomcat接收到Client的HTTP请求时,Tomcat从线程池中取出一个 ...
- 搭建开发环境(React Native)
来源:http://reactnative.cn/docs/0.31/getting-started.html 在GitHub上修改这篇文档 欢迎使用React Native!这篇文档会帮助你搭建基本 ...
- .NET/C# 中你可以在代码中写多个 Main 函数,然后按需要随时切换
.NET/C# 程序从 Main 函数开始执行,基本上各种书籍资料都是这么写的.不过,我们可以写多个 Main 函数,然后在项目文件中设置应该选择哪一个 Main 函数. 你可能会觉得这样没有什么用, ...
- 三:背包DP
01背包问题描述 已知:有一个容量为V的背包和N件物品,第i件物品的重量是weight[i],收益是cost[i]. 限制:每种物品只有一件,可以选择放或者不放 问题:在不超过背包容量的情况下,最多能 ...
- PhoneGap 获得APP的VersionName
1.首先安装cordova-plugin-app-version cordova plugin add cordova-plugin-app-version 2. 调用方法如下 function ge ...
- Think in java.chm 第14章 多线程
例子1引入线程概念通过得到当前线程方式循环主线程做某事 例子2演示了在主线程之外开启多个线程的基本方式 ( new一个extends Thread ) 例子3 ( task extends Threa ...