SlideShare a Scribd company logo
JVM and Garbage Collection


                by marcos.garcia@savoirfairelinux.com, Jan 2013
JVM?
●   Bytecode interpreter




                   http://viralpatel.net/blogs/java-virtual-machine-an-inside-story/
JVM Memory Vocabulary
●   Runtime data areas
    –   PC register:
        ●   One for each thread
        ●   Points to current execution code of each thread
    –   JVM stacks
        ●   One dedicated stack for each thread
        ●
            Holds many stack frames, one for each invoked method
             –   Every frame has 3 registers
    –   Heap
        ●   Shared among all threads
        ●   Stores Java objects.
        ●   Cleaned up by GC
    –   Method area
        ●
            Shared among all threads
        ●
            Contains method code (class implementations)
        ●
            Has a Runtime constant pool
    –   Native method stack (just for “native methods”

                             http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-2.html#jvms-2.5
JVM Stack
●   Stack Frame
    –   Used to store data and partial results, as well as to
        perform dynamic linking, return values for methods, and
        dispatch exceptions.
    –   Describes all the needed information to run a method,
        including current method stack as well as other JVM
        shared spaces
●   Stack Frame registers (one per method
    being executed)
    –   Local Vars, used by current method
        invocation
    –   Frame data / Execution environment, used
        for internal stack operations
    –   Optop / Operand stack (for bytecode),
        reference to runtime constant pool
         ●   It is a LIFO stack, need push/pop operations

                                                                  http://performeister.tistory.com/38
JVM Heap
●   Two heap memory types             ●   Other memory
    –   Young Generation Memory           –   Permanent Generation
        ●   To/From Survivor spaces       –   Native memory (because of
        ●   Eden space                        native memory references,
    –   Old Generation Memory                 to the underlying OS)
Garbage collection
●   Principle: Generational collection or “weak generational hypothesis”
    –   Most allocated objects are not referenced (considered live) for long, that is,
        they die young
    –   Few references from older to younger objects exist
●   Minor GC
    –   Young generation collections occur relatively frequently and are efficient and
        fast because the young generation space is usually small and likely to
        contain a lot of objects that are no longer referenced.
●   Major GC
    –   Objects that survive some number of young generation collections are
        eventually promoted, or tenured, to the old generation




        http://www.oracle.com/technetwork/java/javase/tech/memorymanagement-whitepaper-1-150020.pdf
Young/Old Memory explained

●   Young Space
    –   Eden
        ●   Any object created inside a method or as a class variable
    –   2 survivor spaces (From/To)
        ●   Objects in use, that have survived at least one Minor GC
        ●   1 space empty, other full. Swaps on every GC pass
●   Old (Tenured)
    –   Objects referenced since a long time ago, still being used
    –   Very big objects are created directly in Old space


                            http://java-espresso.blogspot.ca/2011/05/heap-structure-in-jvm.html
GC example
●   Serial Collector (not currently used in modern JVM)




     http://www.oracle.com/technetwork/java/javase/tech/memorymanagement-whitepaper-1-150020.pdf
Parallel and CMS GC
●   CMS is the most used GC implementation
Heap fragmentation
●   We need contiguous space for memory allocation
●   GC also relocates (called compactation) objects to reduce fragmentation
G1 collector (JDK 6 & 7)
●   Garbage-First (G1) collector: 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. Designed for applications that:
     –   Can operate concurrently with applications threads like the CMS collector.
     –   Compact free space without lengthy GC induced pause times.
     –   Need more predictable GC pause durations.
     –   Do not want to sacrifice a lot of throughput performance.
     –   Do not require a much larger Java heap.
●   G1 is planned as the long term replacement for the Concurrent Mark-Sweep Collector (CMS).
●   Better than CMS.
     –   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.
     –   G1 offers more predictable garbage collection pauses than the CMS collector, and allows users to specify
         desired pause targets.




    http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/G1GettingStarted/index.html
G1 Heap Fragmentation




     Young
      GC
Heap evolution
  ●   Regular case      ●   OOM case




Tool: jconsole
Heap evolution
 ●   Regular case                   ●   OOM case




Tool: websphere resource analyzer
Ad

More Related Content

What's hot (20)

Graal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them AllGraal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them All
Thomas Wuerthinger
 
JVM Memory Management Details
JVM Memory Management DetailsJVM Memory Management Details
JVM Memory Management Details
Azul Systems Inc.
 
Basics of reflection in java
Basics of reflection in javaBasics of reflection in java
Basics of reflection in java
kim.mens
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Haribabu Nandyal Padmanaban
 
GraalVM Overview Compact version
GraalVM Overview Compact versionGraalVM Overview Compact version
GraalVM Overview Compact version
scalaconfjp
 
Garbage collection
Garbage collectionGarbage collection
Garbage collection
Somya Bagai
 
Performance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionPerformance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage Collection
Haribabu Nandyal Padmanaban
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
Math-Circle
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
baabtra.com - No. 1 supplier of quality freshers
 
Jvm Architecture
Jvm ArchitectureJvm Architecture
Jvm Architecture
ThirupathiReddy Vajjala
 
Understanding Java Garbage Collection
Understanding Java Garbage CollectionUnderstanding Java Garbage Collection
Understanding Java Garbage Collection
Azul Systems Inc.
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
Pratik Soares
 
JAVA PPT Part-1 BY ADI.pdf
JAVA PPT Part-1 BY ADI.pdfJAVA PPT Part-1 BY ADI.pdf
JAVA PPT Part-1 BY ADI.pdf
Prof. Dr. K. Adisesha
 
Java garbage collector JVM Garbage collection by Jeetendra Mandal
Java garbage collector JVM Garbage collection by Jeetendra MandalJava garbage collector JVM Garbage collection by Jeetendra Mandal
Java garbage collector JVM Garbage collection by Jeetendra Mandal
jeetendra mandal
 
Core Java
Core JavaCore Java
Core Java
Priyanka Pradhan
 
QSpiders - Jdk Jvm Jre and Jit
QSpiders - Jdk Jvm Jre and JitQSpiders - Jdk Jvm Jre and Jit
QSpiders - Jdk Jvm Jre and Jit
Qspiders - Software Testing Training Institute
 
Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programming
Elizabeth Thomas
 
Intro to Java
Intro to JavaIntro to Java
Intro to Java
karianneban
 
Java
JavaJava
Java
Tony Nguyen
 
4장. Class Loader
4장. Class Loader4장. Class Loader
4장. Class Loader
김 한도
 
Graal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them AllGraal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them All
Thomas Wuerthinger
 
JVM Memory Management Details
JVM Memory Management DetailsJVM Memory Management Details
JVM Memory Management Details
Azul Systems Inc.
 
Basics of reflection in java
Basics of reflection in javaBasics of reflection in java
Basics of reflection in java
kim.mens
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Haribabu Nandyal Padmanaban
 
GraalVM Overview Compact version
GraalVM Overview Compact versionGraalVM Overview Compact version
GraalVM Overview Compact version
scalaconfjp
 
Garbage collection
Garbage collectionGarbage collection
Garbage collection
Somya Bagai
 
Performance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionPerformance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage Collection
Haribabu Nandyal Padmanaban
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
Math-Circle
 
Understanding Java Garbage Collection
Understanding Java Garbage CollectionUnderstanding Java Garbage Collection
Understanding Java Garbage Collection
Azul Systems Inc.
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
Pratik Soares
 
Java garbage collector JVM Garbage collection by Jeetendra Mandal
Java garbage collector JVM Garbage collection by Jeetendra MandalJava garbage collector JVM Garbage collection by Jeetendra Mandal
Java garbage collector JVM Garbage collection by Jeetendra Mandal
jeetendra mandal
 
Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programming
Elizabeth Thomas
 
4장. Class Loader
4장. Class Loader4장. Class Loader
4장. Class Loader
김 한도
 

Viewers also liked (20)

An Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in JavaAn Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in Java
Abhishek Asthana
 
Jvm internals
Jvm internalsJvm internals
Jvm internals
Luiz Fernando Teston
 
3. jvm
3. jvm3. jvm
3. jvm
Indu Sharma Bhardwaj
 
Jvm gc那点事
Jvm gc那点事Jvm gc那点事
Jvm gc那点事
boboj
 
Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011
Doug Hawkins
 
Java Virtual Machine - Internal Architecture
Java Virtual Machine - Internal ArchitectureJava Virtual Machine - Internal Architecture
Java Virtual Machine - Internal Architecture
subnesh
 
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIs
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIsCS6270 Virtual Machines - Java Virtual Machine Architecture and APIs
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIs
Kwangshin Oh
 
Java gc and JVM optimization
Java gc  and JVM optimizationJava gc  and JVM optimization
Java gc and JVM optimization
Rajan Jethva
 
Understanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual MachineUnderstanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual Machine
National Cheng Kung University
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Niko Vuokko
 
Java beans
Java beansJava beans
Java beans
Ravi Kant Sahu
 
Introduction to Data Science and Analytics
Introduction to Data Science and AnalyticsIntroduction to Data Science and Analytics
Introduction to Data Science and Analytics
Srinath Perera
 
Introduction on Data Science
Introduction on Data ScienceIntroduction on Data Science
Introduction on Data Science
Edureka!
 
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Svetlin Nakov
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
ANOOP V S
 
Aspek spiritual resort based management
Aspek spiritual resort based managementAspek spiritual resort based management
Aspek spiritual resort based management
Sudirman Sultan
 
Global summit full agenda 1 (1)
Global summit full agenda 1 (1)Global summit full agenda 1 (1)
Global summit full agenda 1 (1)
MobileDiagnosis Non Profit Association
 
SLO County Hospitality Social Media Report 2012
SLO County Hospitality Social Media Report 2012SLO County Hospitality Social Media Report 2012
SLO County Hospitality Social Media Report 2012
Whizbang
 
Presentasi database terdistribusi new 2
Presentasi database terdistribusi new 2Presentasi database terdistribusi new 2
Presentasi database terdistribusi new 2
ichallan
 
Building search-driven Windows 8 and Windows Phone 8 apps for SharePoint Serv...
Building search-driven Windows 8 and Windows Phone 8 apps for SharePoint Serv...Building search-driven Windows 8 and Windows Phone 8 apps for SharePoint Serv...
Building search-driven Windows 8 and Windows Phone 8 apps for SharePoint Serv...
Joris Poelmans
 
An Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in JavaAn Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in Java
Abhishek Asthana
 
Jvm gc那点事
Jvm gc那点事Jvm gc那点事
Jvm gc那点事
boboj
 
Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011
Doug Hawkins
 
Java Virtual Machine - Internal Architecture
Java Virtual Machine - Internal ArchitectureJava Virtual Machine - Internal Architecture
Java Virtual Machine - Internal Architecture
subnesh
 
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIs
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIsCS6270 Virtual Machines - Java Virtual Machine Architecture and APIs
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIs
Kwangshin Oh
 
Java gc and JVM optimization
Java gc  and JVM optimizationJava gc  and JVM optimization
Java gc and JVM optimization
Rajan Jethva
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Niko Vuokko
 
Introduction to Data Science and Analytics
Introduction to Data Science and AnalyticsIntroduction to Data Science and Analytics
Introduction to Data Science and Analytics
Srinath Perera
 
Introduction on Data Science
Introduction on Data ScienceIntroduction on Data Science
Introduction on Data Science
Edureka!
 
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Svetlin Nakov
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
ANOOP V S
 
Aspek spiritual resort based management
Aspek spiritual resort based managementAspek spiritual resort based management
Aspek spiritual resort based management
Sudirman Sultan
 
SLO County Hospitality Social Media Report 2012
SLO County Hospitality Social Media Report 2012SLO County Hospitality Social Media Report 2012
SLO County Hospitality Social Media Report 2012
Whizbang
 
Presentasi database terdistribusi new 2
Presentasi database terdistribusi new 2Presentasi database terdistribusi new 2
Presentasi database terdistribusi new 2
ichallan
 
Building search-driven Windows 8 and Windows Phone 8 apps for SharePoint Serv...
Building search-driven Windows 8 and Windows Phone 8 apps for SharePoint Serv...Building search-driven Windows 8 and Windows Phone 8 apps for SharePoint Serv...
Building search-driven Windows 8 and Windows Phone 8 apps for SharePoint Serv...
Joris Poelmans
 
Ad

Similar to Quick introduction to Java Garbage Collector (JVM GC) (20)

JVM Performance Tuning
JVM Performance TuningJVM Performance Tuning
JVM Performance Tuning
Jeremy Leisy
 
Java and cgroups eng
Java and cgroups engJava and cgroups eng
Java and cgroups eng
Ralf Ernst
 
The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friend
Kai Koenig
 
Jvm is-your-friend
Jvm is-your-friendJvm is-your-friend
Jvm is-your-friend
ColdFusionConference
 
Java programing considering performance
Java programing considering performanceJava programing considering performance
Java programing considering performance
Roger Xia
 
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
 
Java 2
Java 2Java 2
Java 2
KadarkaraiSelvam
 
Software Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and FlamegraphsSoftware Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and Flamegraphs
Isuru Perera
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
Mohammed Fazuluddin
 
Javasession10
Javasession10Javasession10
Javasession10
Rajeev Kumar
 
Jvm problem diagnostics
Jvm problem diagnosticsJvm problem diagnostics
Jvm problem diagnostics
Danijel Mitar
 
Controlling Memory Footprint at All Layers: Linux Kernel, Applications, Libra...
Controlling Memory Footprint at All Layers: Linux Kernel, Applications, Libra...Controlling Memory Footprint at All Layers: Linux Kernel, Applications, Libra...
Controlling Memory Footprint at All Layers: Linux Kernel, Applications, Libra...
peknap
 
Towards "write once - run whenever possible" with Safety Critical Java af Ben...
Towards "write once - run whenever possible" with Safety Critical Java af Ben...Towards "write once - run whenever possible" with Safety Critical Java af Ben...
Towards "write once - run whenever possible" with Safety Critical Java af Ben...
InfinIT - Innovationsnetværket for it
 
Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)
Martijn Verburg
 
Profiler Guided Java Performance Tuning
Profiler Guided Java Performance TuningProfiler Guided Java Performance Tuning
Profiler Guided Java Performance Tuning
osa_ora
 
Basics of JVM Tuning
Basics of JVM TuningBasics of JVM Tuning
Basics of JVM Tuning
Vladislav Gangan
 
Stack Frame Protection
Stack Frame ProtectionStack Frame Protection
Stack Frame Protection
Conferencias FIST
 
Java and the JVM
Java and the JVMJava and the JVM
Java and the JVM
Manish Pandit
 
Looming Marvelous - Virtual Threads in Java Javaland.pdf
Looming Marvelous - Virtual Threads in Java Javaland.pdfLooming Marvelous - Virtual Threads in Java Javaland.pdf
Looming Marvelous - Virtual Threads in Java Javaland.pdf
jexp
 
A quick view about Java Virtual Machine
A quick view about Java Virtual MachineA quick view about Java Virtual Machine
A quick view about Java Virtual Machine
João Santana
 
JVM Performance Tuning
JVM Performance TuningJVM Performance Tuning
JVM Performance Tuning
Jeremy Leisy
 
Java and cgroups eng
Java and cgroups engJava and cgroups eng
Java and cgroups eng
Ralf Ernst
 
The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friend
Kai Koenig
 
Java programing considering performance
Java programing considering performanceJava programing considering performance
Java programing considering performance
Roger Xia
 
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
 
Software Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and FlamegraphsSoftware Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and Flamegraphs
Isuru Perera
 
Jvm problem diagnostics
Jvm problem diagnosticsJvm problem diagnostics
Jvm problem diagnostics
Danijel Mitar
 
Controlling Memory Footprint at All Layers: Linux Kernel, Applications, Libra...
Controlling Memory Footprint at All Layers: Linux Kernel, Applications, Libra...Controlling Memory Footprint at All Layers: Linux Kernel, Applications, Libra...
Controlling Memory Footprint at All Layers: Linux Kernel, Applications, Libra...
peknap
 
Towards "write once - run whenever possible" with Safety Critical Java af Ben...
Towards "write once - run whenever possible" with Safety Critical Java af Ben...Towards "write once - run whenever possible" with Safety Critical Java af Ben...
Towards "write once - run whenever possible" with Safety Critical Java af Ben...
InfinIT - Innovationsnetværket for it
 
Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)
Martijn Verburg
 
Profiler Guided Java Performance Tuning
Profiler Guided Java Performance TuningProfiler Guided Java Performance Tuning
Profiler Guided Java Performance Tuning
osa_ora
 
Looming Marvelous - Virtual Threads in Java Javaland.pdf
Looming Marvelous - Virtual Threads in Java Javaland.pdfLooming Marvelous - Virtual Threads in Java Javaland.pdf
Looming Marvelous - Virtual Threads in Java Javaland.pdf
jexp
 
A quick view about Java Virtual Machine
A quick view about Java Virtual MachineA quick view about Java Virtual Machine
A quick view about Java Virtual Machine
João Santana
 
Ad

More from Marcos García (6)

Puts and calls in stock options
Puts and calls in stock optionsPuts and calls in stock options
Puts and calls in stock options
Marcos García
 
Cloud economics design, capacity and operational concerns
Cloud economics  design, capacity and operational concernsCloud economics  design, capacity and operational concerns
Cloud economics design, capacity and operational concerns
Marcos García
 
Welcome to icehouse
Welcome to icehouseWelcome to icehouse
Welcome to icehouse
Marcos García
 
Initial presentation of swift (for montreal user group)
Initial presentation of swift (for montreal user group)Initial presentation of swift (for montreal user group)
Initial presentation of swift (for montreal user group)
Marcos García
 
Initial presentation of openstack (for montreal user group)
Initial presentation of openstack (for montreal user group)Initial presentation of openstack (for montreal user group)
Initial presentation of openstack (for montreal user group)
Marcos García
 
Solr features
Solr featuresSolr features
Solr features
Marcos García
 
Puts and calls in stock options
Puts and calls in stock optionsPuts and calls in stock options
Puts and calls in stock options
Marcos García
 
Cloud economics design, capacity and operational concerns
Cloud economics  design, capacity and operational concernsCloud economics  design, capacity and operational concerns
Cloud economics design, capacity and operational concerns
Marcos García
 
Initial presentation of swift (for montreal user group)
Initial presentation of swift (for montreal user group)Initial presentation of swift (for montreal user group)
Initial presentation of swift (for montreal user group)
Marcos García
 
Initial presentation of openstack (for montreal user group)
Initial presentation of openstack (for montreal user group)Initial presentation of openstack (for montreal user group)
Initial presentation of openstack (for montreal user group)
Marcos García
 

Recently uploaded (20)

HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 

Quick introduction to Java Garbage Collector (JVM GC)

  • 1. JVM and Garbage Collection by [email protected], Jan 2013
  • 2. JVM? ● Bytecode interpreter http://viralpatel.net/blogs/java-virtual-machine-an-inside-story/
  • 3. JVM Memory Vocabulary ● Runtime data areas – PC register: ● One for each thread ● Points to current execution code of each thread – JVM stacks ● One dedicated stack for each thread ● Holds many stack frames, one for each invoked method – Every frame has 3 registers – Heap ● Shared among all threads ● Stores Java objects. ● Cleaned up by GC – Method area ● Shared among all threads ● Contains method code (class implementations) ● Has a Runtime constant pool – Native method stack (just for “native methods” http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-2.html#jvms-2.5
  • 4. JVM Stack ● Stack Frame – Used to store data and partial results, as well as to perform dynamic linking, return values for methods, and dispatch exceptions. – Describes all the needed information to run a method, including current method stack as well as other JVM shared spaces ● Stack Frame registers (one per method being executed) – Local Vars, used by current method invocation – Frame data / Execution environment, used for internal stack operations – Optop / Operand stack (for bytecode), reference to runtime constant pool ● It is a LIFO stack, need push/pop operations http://performeister.tistory.com/38
  • 5. JVM Heap ● Two heap memory types ● Other memory – Young Generation Memory – Permanent Generation ● To/From Survivor spaces – Native memory (because of ● Eden space native memory references, – Old Generation Memory to the underlying OS)
  • 6. Garbage collection ● Principle: Generational collection or “weak generational hypothesis” – Most allocated objects are not referenced (considered live) for long, that is, they die young – Few references from older to younger objects exist ● Minor GC – Young generation collections occur relatively frequently and are efficient and fast because the young generation space is usually small and likely to contain a lot of objects that are no longer referenced. ● Major GC – Objects that survive some number of young generation collections are eventually promoted, or tenured, to the old generation http://www.oracle.com/technetwork/java/javase/tech/memorymanagement-whitepaper-1-150020.pdf
  • 7. Young/Old Memory explained ● Young Space – Eden ● Any object created inside a method or as a class variable – 2 survivor spaces (From/To) ● Objects in use, that have survived at least one Minor GC ● 1 space empty, other full. Swaps on every GC pass ● Old (Tenured) – Objects referenced since a long time ago, still being used – Very big objects are created directly in Old space http://java-espresso.blogspot.ca/2011/05/heap-structure-in-jvm.html
  • 8. GC example ● Serial Collector (not currently used in modern JVM) http://www.oracle.com/technetwork/java/javase/tech/memorymanagement-whitepaper-1-150020.pdf
  • 9. Parallel and CMS GC ● CMS is the most used GC implementation
  • 10. Heap fragmentation ● We need contiguous space for memory allocation ● GC also relocates (called compactation) objects to reduce fragmentation
  • 11. G1 collector (JDK 6 & 7) ● Garbage-First (G1) collector: 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. Designed for applications that: – Can operate concurrently with applications threads like the CMS collector. – Compact free space without lengthy GC induced pause times. – Need more predictable GC pause durations. – Do not want to sacrifice a lot of throughput performance. – Do not require a much larger Java heap. ● G1 is planned as the long term replacement for the Concurrent Mark-Sweep Collector (CMS). ● Better than CMS. – 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. – G1 offers more predictable garbage collection pauses than the CMS collector, and allows users to specify desired pause targets. http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/G1GettingStarted/index.html
  • 13. Heap evolution ● Regular case ● OOM case Tool: jconsole
  • 14. Heap evolution ● Regular case ● OOM case Tool: websphere resource analyzer