SlideShare a Scribd company logo
Sun JDK 1.6 内存管理
       实现篇
        毕玄
  2010-10、2010-11
目标
• 掌握内存管理的通常实现方法
• 了解Sun JDK是如何实现内存管理的,以及
  做了哪些优化
• 了解JRockit做了哪些优化
OS内存管理




  图片来源于JavaOne 2010 《where does all native memory go》 Session
OS内存管理




  图片来源于JavaOne 2010 《where does all native memory go》 Session
OS内存管理




  图片来源于JavaOne 2010 《where does all native memory go》 Session
OS内存管理




  图片来源于JavaOne 2010 《where does all native memory go》 Session
OS内存管理




  图片来源于JavaOne 2010 《where does all native memory go》 Session
内存分配和回收
• allocate

     A       B    C   D
内存分配和回收
• allocate

     A       B    C   B



                          freelist
内存分配和回收
• fragmenation

    A     B          C        B



                                                freelist

                 sorry,no space

                              i need allocate

                 E
内存分配和回收
• Compaction

    A      C      B           B



                free space pointer


  – need update pointer
Discussion
• how to find garbage and claim it..
  – let’s talk about this question first
GC Algorithm
• Reference Counting
• Tracing
  – Mark-Sweep
  – Mark-Compact
  – Copying
GC Algorithm Details
• Reference Counting




                图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Reference Counting




                图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Reference Counting




                图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Reference Counting




                图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Reference Counting




                图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Reference Counting




                图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Reference Counting




                图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Reference Counting
  – extra space,time overhead
  – non-moving
  – cyclic garbage
GC Algorithm Details
• Advance Reference Counting
  – two-bit reference counts
     • when max count(3) is reached,object becomes “sticky”
  – buffer reference updates
  – use a backup gc algorithm to handle cyclic garbage
    and “sticky” objects
  – complex,but still non-moving
GC Algorithm Details
• Tracing – Mark-Sweep




                图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Tracing – Mark-Sweep




                图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Tracing – Mark-Sweep




                图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Tracing – Mark-Sweep




                图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Tracing – Mark-Sweep




                图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Tracing – Mark-Sweep




                图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Tracing – Mark-Sweep
  – need scan all objects,so if java heap becomes
    larger,then gc slower
  – 可清除所有的Garbage
  – 内存碎片,分配低效
  – 需要在一定的时机触发
GC Algorithm Details
• Tracing – Mark-Compact




                图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Tracing – Mark-Compact
  – 没有内存碎片,分配高效
  – 增加了回收需要耗费的时间
  – 需要更新所有移动过的object的ref pointer
  – 需要在一定时机触发
GC Algorithm Details
• Tracing – Copying(a special case)




                  图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Tracing – Copying(a special case)




                  图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Tracing – Copying(a special case)




                  图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Tracing – Copying(a special case)




                  图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Tracing – Copying(a special case)




                  图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Tracing – Copying(a special case)




                  图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
GC Algorithm Details
• Tracing – Copying(a special case)
  – only need scan live objects,so gc speed only
    decided by lds
  – no fragmentation
  – need update object pointer
  – need keep an empty memory area
GC Algorithm Summary
• Why gc need stop the world?
  – Mark-Sweep,Mark-Compact
     • if ref changes or new object created when marking;
     • compact need update pointer,so...
  – Copying
     • copying need update pointer,so...
目标
• 掌握内存管理的通常实现方法
• 了解Sun JDK是如何实现内存管理的,以及
  做了哪些优化
• 了解JRockit做了哪些优化
GC in Hotspot
• rootset
  – runtime stack
  – static or global variables
  – jni handles
  – jvm handles
GC in Hotspot
• Generational GC
  – most objects are temp-lived
     • so JDK decide split heap into two generations to use gc
       algorithm properly

        Copying             Mark-Sweep or Mark-Compact

        New                           Old
GC in Hotspot
• how to stop the world
  – safepoint at ref change
     • safepoint is a memory page check
     • compile
  – when gc need execute,it submit “stop thread”
    request to jvm core,then jvm core set the memory
    page not readable
  – when code execute to safepoint, check the
    memory page if readable,if not then fail and stop
GC in Hotspot
• YGC
  – allocate is slow,because need lock
  – how to make allocate faster?
     TLAB       Use CAS replace lock
• do u have any other ideas?
GC in Hotspot
• YGC
  – how to find live objects faster?
    Live Maps             Scan Algorithm
• do u have any other ideas?
GC in Hotspot
• YGC
  – how to handle object in old gen ref new gen
    object
  Write Barrier & Card table
• do u have any other ideas?
GC in Hotspot
• YGC
  – how to make scan and copying faster?
    Parallel
    Adaptive based on runtime feedback
• do u have any other ideas?
GC in Hotspot
• FGC
  – optimize for throughput
     • parallel
  – optimize for low latency
     • concurrent
GC in Hotspot
• FGC – parallel
  – based on Mark-Compact
  – allocate use the bump pointer
GC in Hotspot
• FGC – parallel
  – how to make mark phase faster?
    Parallel
• do u have any other ideas?
GC in Hotspot
• FGC – parallel
  – how to make compact phase faster?
   Partial Compact when use ParallelOldGC
• do u have any other ideas?
GC in Hotspot
• FGC – concurrent
  – based on mark-sweep
  – when concurrent gc executes,ref may be changed
    and new objects may be created,how to solve the
    question?
GC in Hotspot
• FGC – concurrent
  – when concurrent gc executes,ref may be changed
    and new objects may be created,how to solve the
    question?
    Write Barrier & Card Table
GC in Hotspot
• FGC – concurrent
  – how to mark remark phase faster?
   add a preclean phase
• do u have any other ideas?
Futhermore – G1
• Region-based GC
• how to behave better?
  garbage first
  hot regions
目标
• 掌握内存管理的通常实现方法
• 了解Sun JDK是如何实现内存管理的,以及
  做了哪些优化
• 了解JRockit做了哪些优化
Futhermore – Open eyes
• JRockit GC
  – YGC
     • pinned object for semi-long lived object
     • keep area
  – Mark
     • Two-Color for prefetching
  – Compaction
     • partial,for example some objects not be compacted because
       many objects ref them.
  – Adjust gens,size adaptive based on runtime feedback
目标
• 掌握内存管理的通常实现方法
• 了解Sun JDK是如何实现内存管理的,以及
  做了哪些优化
• 了解JRockit做了哪些优化
how to research jvm
• JDK Source codes
• References
References
• JVM References

More Related Content

Similar to Sun jdk 1.6内存管理 -实现篇 -毕玄

淺談 Java GC 原理、調教和 新發展
淺談 Java GC 原理、調教和新發展淺談 Java GC 原理、調教和新發展
淺談 Java GC 原理、調教和 新發展
Leon Chen
 
New Algorithms in Java
New Algorithms in JavaNew Algorithms in Java
New Algorithms in Java
Krystian Zybała
 
JVM @ Taobao - QCon Hangzhou 2011
JVM @ Taobao - QCon Hangzhou 2011JVM @ Taobao - QCon Hangzhou 2011
JVM @ Taobao - QCon Hangzhou 2011
Kris Mok
 
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)OpenBlend society
 
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDBMongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDBBoxed Ice
 
Low latency Java apps
Low latency Java appsLow latency Java apps
Low latency Java apps
Simon Ritter
 
Introduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission ControlIntroduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission Control
Leon Chen
 
JavaOne summary
JavaOne summaryJavaOne summary
JavaOne summary
bluedavy lin
 
Performance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionPerformance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage Collection
Haribabu Nandyal Padmanaban
 
Progress_190130
Progress_190130Progress_190130
Progress_190130
Hyo jeong Lee
 
Java Performance Monitoring & Tuning
Java Performance Monitoring & TuningJava Performance Monitoring & Tuning
Java Performance Monitoring & Tuning
Muhammed Shakir
 
Gc algorithms
Gc algorithmsGc algorithms
Gc algorithms
Michał Warecki
 
Java Garbage Collector and The Memory Model
Java Garbage Collector and The Memory ModelJava Garbage Collector and The Memory Model
Java Garbage Collector and The Memory Model
Ernesto Arroyo Ron
 
JVM Performance Tuning
JVM Performance TuningJVM Performance Tuning
JVM Performance Tuning
Jeremy Leisy
 
Java performance monitoring
Java performance monitoringJava performance monitoring
Java performance monitoring
Simon Ritter
 
ZGC-SnowOne.pdf
ZGC-SnowOne.pdfZGC-SnowOne.pdf
ZGC-SnowOne.pdf
Monica Beckwith
 
Jvm lecture
Jvm lectureJvm lecture
Jvm lecturesdslnmd
 
[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes
Bruno Borges
 
Progress_190118
Progress_190118Progress_190118
Progress_190118
Hyo jeong Lee
 
«Большие объёмы данных и сборка мусора в Java
«Большие объёмы данных и сборка мусора в Java«Большие объёмы данных и сборка мусора в Java
«Большие объёмы данных и сборка мусора в Java
Olga Lavrentieva
 

Similar to Sun jdk 1.6内存管理 -实现篇 -毕玄 (20)

淺談 Java GC 原理、調教和 新發展
淺談 Java GC 原理、調教和新發展淺談 Java GC 原理、調教和新發展
淺談 Java GC 原理、調教和 新發展
 
New Algorithms in Java
New Algorithms in JavaNew Algorithms in Java
New Algorithms in Java
 
JVM @ Taobao - QCon Hangzhou 2011
JVM @ Taobao - QCon Hangzhou 2011JVM @ Taobao - QCon Hangzhou 2011
JVM @ Taobao - QCon Hangzhou 2011
 
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
 
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDBMongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
 
Low latency Java apps
Low latency Java appsLow latency Java apps
Low latency Java apps
 
Introduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission ControlIntroduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission Control
 
JavaOne summary
JavaOne summaryJavaOne summary
JavaOne summary
 
Performance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionPerformance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage Collection
 
Progress_190130
Progress_190130Progress_190130
Progress_190130
 
Java Performance Monitoring & Tuning
Java Performance Monitoring & TuningJava Performance Monitoring & Tuning
Java Performance Monitoring & Tuning
 
Gc algorithms
Gc algorithmsGc algorithms
Gc algorithms
 
Java Garbage Collector and The Memory Model
Java Garbage Collector and The Memory ModelJava Garbage Collector and The Memory Model
Java Garbage Collector and The Memory Model
 
JVM Performance Tuning
JVM Performance TuningJVM Performance Tuning
JVM Performance Tuning
 
Java performance monitoring
Java performance monitoringJava performance monitoring
Java performance monitoring
 
ZGC-SnowOne.pdf
ZGC-SnowOne.pdfZGC-SnowOne.pdf
ZGC-SnowOne.pdf
 
Jvm lecture
Jvm lectureJvm lecture
Jvm lecture
 
[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes
 
Progress_190118
Progress_190118Progress_190118
Progress_190118
 
«Большие объёмы данных и сборка мусора в Java
«Большие объёмы данных и сборка мусора в Java«Большие объёмы данных и сборка мусора в Java
«Большие объёмы данных и сборка мусора в Java
 

More from 锐 张

长尾理论(The longtail)版
长尾理论(The longtail)版长尾理论(The longtail)版
长尾理论(The longtail)版锐 张
 
Openstack starter-guide-diablo
Openstack starter-guide-diabloOpenstack starter-guide-diablo
Openstack starter-guide-diablo锐 张
 
基于My sql的分布式数据库实践
基于My sql的分布式数据库实践基于My sql的分布式数据库实践
基于My sql的分布式数据库实践锐 张
 
Redis中文入门手册
Redis中文入门手册Redis中文入门手册
Redis中文入门手册锐 张
 
Redis学习笔记
Redis学习笔记Redis学习笔记
Redis学习笔记锐 张
 
Redis内存存储结构分析
Redis内存存储结构分析Redis内存存储结构分析
Redis内存存储结构分析锐 张
 
淘宝前端优化
淘宝前端优化淘宝前端优化
淘宝前端优化锐 张
 
Sun jdk 1.6内存管理 -调优篇-毕玄
Sun jdk 1.6内存管理 -调优篇-毕玄Sun jdk 1.6内存管理 -调优篇-毕玄
Sun jdk 1.6内存管理 -调优篇-毕玄锐 张
 
Sun jdk 1.6内存管理 -使用篇-毕玄
Sun jdk 1.6内存管理 -使用篇-毕玄Sun jdk 1.6内存管理 -使用篇-毕玄
Sun jdk 1.6内存管理 -使用篇-毕玄锐 张
 
Sun jdk-1.6-gc
Sun jdk-1.6-gcSun jdk-1.6-gc
Sun jdk-1.6-gc锐 张
 
Redis介绍
Redis介绍Redis介绍
Redis介绍锐 张
 
Redis深入浅出
Redis深入浅出Redis深入浅出
Redis深入浅出锐 张
 
Green plum培训材料
Green plum培训材料Green plum培训材料
Green plum培训材料锐 张
 
Greenplum技术
Greenplum技术Greenplum技术
Greenplum技术锐 张
 
新时代的分析型云数据库 Greenplum
新时代的分析型云数据库 Greenplum新时代的分析型云数据库 Greenplum
新时代的分析型云数据库 Greenplum锐 张
 
服务器端性能优化 提升Qps、rt
服务器端性能优化 提升Qps、rt服务器端性能优化 提升Qps、rt
服务器端性能优化 提升Qps、rt锐 张
 
新浪云计算公开课第二期:Sae平台的灵活应用(吕毅、魏世江)
新浪云计算公开课第二期:Sae平台的灵活应用(吕毅、魏世江)新浪云计算公开课第二期:Sae平台的灵活应用(吕毅、魏世江)
新浪云计算公开课第二期:Sae平台的灵活应用(吕毅、魏世江)锐 张
 
新浪云计算公开课第一期:Let’s run @ sae(丛磊)
新浪云计算公开课第一期:Let’s run @ sae(丛磊)新浪云计算公开课第一期:Let’s run @ sae(丛磊)
新浪云计算公开课第一期:Let’s run @ sae(丛磊)锐 张
 
Lamp高性能设计
Lamp高性能设计Lamp高性能设计
Lamp高性能设计锐 张
 
亚马逊云计算Aws
亚马逊云计算Aws亚马逊云计算Aws
亚马逊云计算Aws锐 张
 

More from 锐 张 (20)

长尾理论(The longtail)版
长尾理论(The longtail)版长尾理论(The longtail)版
长尾理论(The longtail)版
 
Openstack starter-guide-diablo
Openstack starter-guide-diabloOpenstack starter-guide-diablo
Openstack starter-guide-diablo
 
基于My sql的分布式数据库实践
基于My sql的分布式数据库实践基于My sql的分布式数据库实践
基于My sql的分布式数据库实践
 
Redis中文入门手册
Redis中文入门手册Redis中文入门手册
Redis中文入门手册
 
Redis学习笔记
Redis学习笔记Redis学习笔记
Redis学习笔记
 
Redis内存存储结构分析
Redis内存存储结构分析Redis内存存储结构分析
Redis内存存储结构分析
 
淘宝前端优化
淘宝前端优化淘宝前端优化
淘宝前端优化
 
Sun jdk 1.6内存管理 -调优篇-毕玄
Sun jdk 1.6内存管理 -调优篇-毕玄Sun jdk 1.6内存管理 -调优篇-毕玄
Sun jdk 1.6内存管理 -调优篇-毕玄
 
Sun jdk 1.6内存管理 -使用篇-毕玄
Sun jdk 1.6内存管理 -使用篇-毕玄Sun jdk 1.6内存管理 -使用篇-毕玄
Sun jdk 1.6内存管理 -使用篇-毕玄
 
Sun jdk-1.6-gc
Sun jdk-1.6-gcSun jdk-1.6-gc
Sun jdk-1.6-gc
 
Redis介绍
Redis介绍Redis介绍
Redis介绍
 
Redis深入浅出
Redis深入浅出Redis深入浅出
Redis深入浅出
 
Green plum培训材料
Green plum培训材料Green plum培训材料
Green plum培训材料
 
Greenplum技术
Greenplum技术Greenplum技术
Greenplum技术
 
新时代的分析型云数据库 Greenplum
新时代的分析型云数据库 Greenplum新时代的分析型云数据库 Greenplum
新时代的分析型云数据库 Greenplum
 
服务器端性能优化 提升Qps、rt
服务器端性能优化 提升Qps、rt服务器端性能优化 提升Qps、rt
服务器端性能优化 提升Qps、rt
 
新浪云计算公开课第二期:Sae平台的灵活应用(吕毅、魏世江)
新浪云计算公开课第二期:Sae平台的灵活应用(吕毅、魏世江)新浪云计算公开课第二期:Sae平台的灵活应用(吕毅、魏世江)
新浪云计算公开课第二期:Sae平台的灵活应用(吕毅、魏世江)
 
新浪云计算公开课第一期:Let’s run @ sae(丛磊)
新浪云计算公开课第一期:Let’s run @ sae(丛磊)新浪云计算公开课第一期:Let’s run @ sae(丛磊)
新浪云计算公开课第一期:Let’s run @ sae(丛磊)
 
Lamp高性能设计
Lamp高性能设计Lamp高性能设计
Lamp高性能设计
 
亚马逊云计算Aws
亚马逊云计算Aws亚马逊云计算Aws
亚马逊云计算Aws
 

Recently uploaded

Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 

Recently uploaded (20)

Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 

Sun jdk 1.6内存管理 -实现篇 -毕玄

  • 1. Sun JDK 1.6 内存管理 实现篇 毕玄 2010-10、2010-11
  • 2. 目标 • 掌握内存管理的通常实现方法 • 了解Sun JDK是如何实现内存管理的,以及 做了哪些优化 • 了解JRockit做了哪些优化
  • 3. OS内存管理 图片来源于JavaOne 2010 《where does all native memory go》 Session
  • 4. OS内存管理 图片来源于JavaOne 2010 《where does all native memory go》 Session
  • 5. OS内存管理 图片来源于JavaOne 2010 《where does all native memory go》 Session
  • 6. OS内存管理 图片来源于JavaOne 2010 《where does all native memory go》 Session
  • 7. OS内存管理 图片来源于JavaOne 2010 《where does all native memory go》 Session
  • 10. 内存分配和回收 • fragmenation A B C B freelist sorry,no space i need allocate E
  • 11. 内存分配和回收 • Compaction A C B B free space pointer – need update pointer
  • 12. Discussion • how to find garbage and claim it.. – let’s talk about this question first
  • 13. GC Algorithm • Reference Counting • Tracing – Mark-Sweep – Mark-Compact – Copying
  • 14. GC Algorithm Details • Reference Counting 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 15. GC Algorithm Details • Reference Counting 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 16. GC Algorithm Details • Reference Counting 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 17. GC Algorithm Details • Reference Counting 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 18. GC Algorithm Details • Reference Counting 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 19. GC Algorithm Details • Reference Counting 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 20. GC Algorithm Details • Reference Counting 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 21. GC Algorithm Details • Reference Counting – extra space,time overhead – non-moving – cyclic garbage
  • 22. GC Algorithm Details • Advance Reference Counting – two-bit reference counts • when max count(3) is reached,object becomes “sticky” – buffer reference updates – use a backup gc algorithm to handle cyclic garbage and “sticky” objects – complex,but still non-moving
  • 23. GC Algorithm Details • Tracing – Mark-Sweep 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 24. GC Algorithm Details • Tracing – Mark-Sweep 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 25. GC Algorithm Details • Tracing – Mark-Sweep 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 26. GC Algorithm Details • Tracing – Mark-Sweep 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 27. GC Algorithm Details • Tracing – Mark-Sweep 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 28. GC Algorithm Details • Tracing – Mark-Sweep 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 29. GC Algorithm Details • Tracing – Mark-Sweep – need scan all objects,so if java heap becomes larger,then gc slower – 可清除所有的Garbage – 内存碎片,分配低效 – 需要在一定的时机触发
  • 30. GC Algorithm Details • Tracing – Mark-Compact 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 31. GC Algorithm Details • Tracing – Mark-Compact – 没有内存碎片,分配高效 – 增加了回收需要耗费的时间 – 需要更新所有移动过的object的ref pointer – 需要在一定时机触发
  • 32. GC Algorithm Details • Tracing – Copying(a special case) 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 33. GC Algorithm Details • Tracing – Copying(a special case) 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 34. GC Algorithm Details • Tracing – Copying(a special case) 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 35. GC Algorithm Details • Tracing – Copying(a special case) 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 36. GC Algorithm Details • Tracing – Copying(a special case) 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 37. GC Algorithm Details • Tracing – Copying(a special case) 图片来源于JavaOne 2010 《The Garbage Collection Mythbusters》 Session by tony,john
  • 38. GC Algorithm Details • Tracing – Copying(a special case) – only need scan live objects,so gc speed only decided by lds – no fragmentation – need update object pointer – need keep an empty memory area
  • 39. GC Algorithm Summary • Why gc need stop the world? – Mark-Sweep,Mark-Compact • if ref changes or new object created when marking; • compact need update pointer,so... – Copying • copying need update pointer,so...
  • 40. 目标 • 掌握内存管理的通常实现方法 • 了解Sun JDK是如何实现内存管理的,以及 做了哪些优化 • 了解JRockit做了哪些优化
  • 41. GC in Hotspot • rootset – runtime stack – static or global variables – jni handles – jvm handles
  • 42. GC in Hotspot • Generational GC – most objects are temp-lived • so JDK decide split heap into two generations to use gc algorithm properly Copying Mark-Sweep or Mark-Compact New Old
  • 43. GC in Hotspot • how to stop the world – safepoint at ref change • safepoint is a memory page check • compile – when gc need execute,it submit “stop thread” request to jvm core,then jvm core set the memory page not readable – when code execute to safepoint, check the memory page if readable,if not then fail and stop
  • 44. GC in Hotspot • YGC – allocate is slow,because need lock – how to make allocate faster? TLAB Use CAS replace lock • do u have any other ideas?
  • 45. GC in Hotspot • YGC – how to find live objects faster? Live Maps Scan Algorithm • do u have any other ideas?
  • 46. GC in Hotspot • YGC – how to handle object in old gen ref new gen object Write Barrier & Card table • do u have any other ideas?
  • 47. GC in Hotspot • YGC – how to make scan and copying faster? Parallel Adaptive based on runtime feedback • do u have any other ideas?
  • 48. GC in Hotspot • FGC – optimize for throughput • parallel – optimize for low latency • concurrent
  • 49. GC in Hotspot • FGC – parallel – based on Mark-Compact – allocate use the bump pointer
  • 50. GC in Hotspot • FGC – parallel – how to make mark phase faster? Parallel • do u have any other ideas?
  • 51. GC in Hotspot • FGC – parallel – how to make compact phase faster? Partial Compact when use ParallelOldGC • do u have any other ideas?
  • 52. GC in Hotspot • FGC – concurrent – based on mark-sweep – when concurrent gc executes,ref may be changed and new objects may be created,how to solve the question?
  • 53. GC in Hotspot • FGC – concurrent – when concurrent gc executes,ref may be changed and new objects may be created,how to solve the question? Write Barrier & Card Table
  • 54. GC in Hotspot • FGC – concurrent – how to mark remark phase faster? add a preclean phase • do u have any other ideas?
  • 55. Futhermore – G1 • Region-based GC • how to behave better? garbage first hot regions
  • 56. 目标 • 掌握内存管理的通常实现方法 • 了解Sun JDK是如何实现内存管理的,以及 做了哪些优化 • 了解JRockit做了哪些优化
  • 57. Futhermore – Open eyes • JRockit GC – YGC • pinned object for semi-long lived object • keep area – Mark • Two-Color for prefetching – Compaction • partial,for example some objects not be compacted because many objects ref them. – Adjust gens,size adaptive based on runtime feedback
  • 58. 目标 • 掌握内存管理的通常实现方法 • 了解Sun JDK是如何实现内存管理的,以及 做了哪些优化 • 了解JRockit做了哪些优化
  • 59. how to research jvm • JDK Source codes • References