SlideShare a Scribd company logo
JVM
A quick view about Java Virtual Machine
Once upon a time...
Java as lang and Platform
Java is also a Programming Language and a Platform. We’ll speak about Java
as Platform in this presentation.
As Language, Java is pretty nice despite of verbosity.
Why use a VM?
Once a program is created, it must be compiled
for each OS. If you want your program for Mac,
compile for Mac. Windows? Same. Linux?
Same…
Furthermore, memory allocation needed be done
manually.
Using JVM, all responsability to handle memory
or run in many OSs is delegated to it.
The JVM abstracts not only the hardware layer
but also the communication with the Operating
System.
How does it work?
Hello.java Hello.class
Javac
JRE
JRE
Java Bytecode
Compiled from "Hello.java"
class HelloJava {
HelloJava();
public static void
main(java.lang.String[]);
}
class HelloJava {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Kotlin Bytecode
Compiled from "Hello.kt"
public final class Hello {
public Hello();
}
class Hello
fun main(args: Array<String>) {
println("Hello World!")
}
Heap
Heap
The JVM has a heap, a runtime data
area from which memory for all
class instances and arrays are
allocated. Is shared by all Threads.
It is where the Objects born, grow
and die. Example:
$ java -Xms128m -Xmx512m -jar
homeboy-1.0-SNAPSHOT.jar
To set the maximum Java heap size
we use the option -Xmx.
to set the initial Java heap size
-Xms.
Heap
Eden Survivor Old
PermGen
PermGen
The JVM also allocate objects apart the heap, at
Permgen.
This area stores class related data from class
definitions, structures, methods, field, and
constants.
PermGen
Despite standing in his name, the memory space
from PermGen is also collected in a FullGC.
IT can cause java.lang.OutOfMemoryError:
PermGen space if it runs out if space. This
happens normally when the exaggerated
amount of classes that are loaded into memory.
“PermGen is Dead. Long live PermGen”
-JDK 8 HotSpot JVM
Metaspace
Metaspace is a new memory space - since java
8 - replacing Permgen.
What makes it different of Permgen?
Instead of allocate memory inside JVM, it
allocates in the OS memory.
Garbage Collector
Garbage Collector - a quick view on Heap (again)
Eden Survivor Old
Heap
Garbage collector - Mark and sweep
On the first cycle, this algorithm marks all accessible objects in all
current threads.
On the second cycle Sweeps all objects which were not marked in
the last cycle.
The Mark and Sweep is outdated, but it was a great learning to deal
with non-referenced objects.
Garbage collector - generational copying
● The idea of this algorithm is to divide objects into generations, young and old generation.
● The new generation is usually smaller than the old one (1/3 of the old).
● The GC scans the younger generation, which does not paralyze the JVM.
● Who "survives" is copied to the Old generation and the space of the Young Generation is
made available again.
● The discard does not remove from the memory yet, it just marks the memory as
available.
● Although it is costly to copy an object to the old generation to another part of the Heap,
few survive, so the cost is low.
● Also, copying fewer objects is still "cheaper" than removing objects.
● When Young is crowded, a minor collect runs. At this point objects are sent to the old
generation.
Garbage collector - generational copying
● Depending on the JVM, large objects have the behavior of already being copied to the Old
generation;
● Generational copying copies the objects to the next in a clustered fashion, optimizing
memory and ensuring that there is no memory fragmentation.
● It is possible to increase the proportion of the space allocated to Young Generation by
the option -XX: NewRatio = 1 (50%). By default, 2/3 will be old and 1/3 will be young; by
changing the value to 1, we will have 1/2 for each area.
Garbage collector - Garbage First (G1)
Although it is considered a generational
algorithm, it does not separates the heap in
two generations, but in many small regions.
Dynamically, the G1 chooses some regions
to be collected (which gives the logical
sense of those regions to be a young gen).
JIT Compiler
JIT Compiler (Just in time) or slow is your granny
JIT compiles Java code in Runtime to improve the application
performance.
But I said before that JVM read Bytecode and runs it in a VM,
right?
The first JVMs were the same, but with each version, the JVM is
increased and brought this new feature to the VM.
JIT Compiler (Just in time)
JIT has the ability to do optimization according to the use of the
program and the current conditions. The so-called hotspots.
What JIT does behind the scene?
It compiles for native platform and runs native code optimizing
the application running.
Thanks =)
By João Santana
joaosantana.ti@gmail.com
github.com/jonss

More Related Content

What's hot (7)

Java JVM
Java JVMJava JVM
Java JVM
KadarkaraiSelvam
 
Memory leak
Memory leakMemory leak
Memory leak
Anandraj Kulkarni
 
Java Virtual Machine
Java Virtual Machine Java Virtual Machine
Java Virtual Machine
profbnk
 
jLove 2020 - Micronaut and graalvm: The power of AoT
jLove 2020 - Micronaut and graalvm: The power of AoTjLove 2020 - Micronaut and graalvm: The power of AoT
jLove 2020 - Micronaut and graalvm: The power of AoT
Iván López Martín
 
Java 2
Java 2Java 2
Java 2
KadarkaraiSelvam
 
Ola Bini Evolving The Java Platform
Ola Bini Evolving The Java PlatformOla Bini Evolving The Java Platform
Ola Bini Evolving The Java Platform
deimos
 
Inside the JVM
Inside the JVMInside the JVM
Inside the JVM
Jim Jagielski
 

Similar to A quick view about Java Virtual Machine (20)

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 virtual machine
Java virtual machineJava virtual machine
Java virtual machine
Nikhil Sharma
 
Garbage collection
Garbage collectionGarbage collection
Garbage collection
Mudit Gupta
 
Java lab lecture 1
Java  lab  lecture 1Java  lab  lecture 1
Java lab lecture 1
vishal choudhary
 
Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
Java Core | Modern Java Concurrency | Martijn Verburg & Ben EvansJava Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
JAX London
 
Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)
Marcos García
 
JVM Magic
JVM MagicJVM Magic
JVM Magic
Baruch Sadogursky
 
Jvm performance tuning
Jvm performance tuningJvm performance tuning
Jvm performance tuning
Igor Igoroshka
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
Sandeep Rawat
 
Jvm internal detail
Jvm internal detailJvm internal detail
Jvm internal detail
Mohammad Faizan
 
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
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
Mr. Akaash
 
JVM memory metrics and rules for detecting possible OOM caused crash
JVM memory metrics and rules for detecting possible OOM caused crashJVM memory metrics and rules for detecting possible OOM caused crash
JVM memory metrics and rules for detecting possible OOM caused crash
Atharva Bhingarkar
 
JVM memory metrics and rules for detecting likely OOM caused crash
JVM memory metrics and rules for detecting likely OOM caused crashJVM memory metrics and rules for detecting likely OOM caused crash
JVM memory metrics and rules for detecting likely OOM caused crash
Ajit Bhingarkar
 
OOPs, OOMs, oh my! Containerizing JVM apps
OOPs, OOMs, oh my! Containerizing JVM appsOOPs, OOMs, oh my! Containerizing JVM apps
OOPs, OOMs, oh my! Containerizing JVM apps
Sematext Group, Inc.
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
Mohammed Fazuluddin
 
Java Performance and Using Java Flight Recorder
Java Performance and Using Java Flight RecorderJava Performance and Using Java Flight Recorder
Java Performance and Using Java Flight Recorder
Isuru Perera
 
Profiler Guided Java Performance Tuning
Profiler Guided Java Performance TuningProfiler Guided Java Performance Tuning
Profiler Guided Java Performance Tuning
osa_ora
 
It's always sunny with OpenJ9
It's always sunny with OpenJ9It's always sunny with OpenJ9
It's always sunny with OpenJ9
DanHeidinga
 
The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friend
Kai Koenig
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
Nikhil Sharma
 
Garbage collection
Garbage collectionGarbage collection
Garbage collection
Mudit Gupta
 
Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
Java Core | Modern Java Concurrency | Martijn Verburg & Ben EvansJava Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
JAX London
 
Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)
Marcos García
 
Jvm performance tuning
Jvm performance tuningJvm performance tuning
Jvm performance tuning
Igor Igoroshka
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
Sandeep Rawat
 
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
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
Mr. Akaash
 
JVM memory metrics and rules for detecting possible OOM caused crash
JVM memory metrics and rules for detecting possible OOM caused crashJVM memory metrics and rules for detecting possible OOM caused crash
JVM memory metrics and rules for detecting possible OOM caused crash
Atharva Bhingarkar
 
JVM memory metrics and rules for detecting likely OOM caused crash
JVM memory metrics and rules for detecting likely OOM caused crashJVM memory metrics and rules for detecting likely OOM caused crash
JVM memory metrics and rules for detecting likely OOM caused crash
Ajit Bhingarkar
 
OOPs, OOMs, oh my! Containerizing JVM apps
OOPs, OOMs, oh my! Containerizing JVM appsOOPs, OOMs, oh my! Containerizing JVM apps
OOPs, OOMs, oh my! Containerizing JVM apps
Sematext Group, Inc.
 
Java Performance and Using Java Flight Recorder
Java Performance and Using Java Flight RecorderJava Performance and Using Java Flight Recorder
Java Performance and Using Java Flight Recorder
Isuru Perera
 
Profiler Guided Java Performance Tuning
Profiler Guided Java Performance TuningProfiler Guided Java Performance Tuning
Profiler Guided Java Performance Tuning
osa_ora
 
It's always sunny with OpenJ9
It's always sunny with OpenJ9It's always sunny with OpenJ9
It's always sunny with OpenJ9
DanHeidinga
 

Recently uploaded (20)

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
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
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
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Build 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHSBuild 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHS
TECH EHS Solution
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
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
 
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
 
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
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
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
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
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
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
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
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Build 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHSBuild 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHS
TECH EHS Solution
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
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
 
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
 
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
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
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
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 

A quick view about Java Virtual Machine

  • 1. JVM A quick view about Java Virtual Machine
  • 2. Once upon a time...
  • 3. Java as lang and Platform Java is also a Programming Language and a Platform. We’ll speak about Java as Platform in this presentation. As Language, Java is pretty nice despite of verbosity.
  • 4. Why use a VM? Once a program is created, it must be compiled for each OS. If you want your program for Mac, compile for Mac. Windows? Same. Linux? Same… Furthermore, memory allocation needed be done manually. Using JVM, all responsability to handle memory or run in many OSs is delegated to it. The JVM abstracts not only the hardware layer but also the communication with the Operating System.
  • 5. How does it work? Hello.java Hello.class Javac JRE JRE
  • 6. Java Bytecode Compiled from "Hello.java" class HelloJava { HelloJava(); public static void main(java.lang.String[]); } class HelloJava { public static void main(String[] args) { System.out.println("Hello World!"); } }
  • 7. Kotlin Bytecode Compiled from "Hello.kt" public final class Hello { public Hello(); } class Hello fun main(args: Array<String>) { println("Hello World!") }
  • 9. Heap The JVM has a heap, a runtime data area from which memory for all class instances and arrays are allocated. Is shared by all Threads. It is where the Objects born, grow and die. Example: $ java -Xms128m -Xmx512m -jar homeboy-1.0-SNAPSHOT.jar To set the maximum Java heap size we use the option -Xmx. to set the initial Java heap size -Xms.
  • 12. PermGen The JVM also allocate objects apart the heap, at Permgen. This area stores class related data from class definitions, structures, methods, field, and constants.
  • 13. PermGen Despite standing in his name, the memory space from PermGen is also collected in a FullGC. IT can cause java.lang.OutOfMemoryError: PermGen space if it runs out if space. This happens normally when the exaggerated amount of classes that are loaded into memory.
  • 14. “PermGen is Dead. Long live PermGen” -JDK 8 HotSpot JVM
  • 15. Metaspace Metaspace is a new memory space - since java 8 - replacing Permgen. What makes it different of Permgen? Instead of allocate memory inside JVM, it allocates in the OS memory.
  • 17. Garbage Collector - a quick view on Heap (again) Eden Survivor Old Heap
  • 18. Garbage collector - Mark and sweep On the first cycle, this algorithm marks all accessible objects in all current threads. On the second cycle Sweeps all objects which were not marked in the last cycle. The Mark and Sweep is outdated, but it was a great learning to deal with non-referenced objects.
  • 19. Garbage collector - generational copying ● The idea of this algorithm is to divide objects into generations, young and old generation. ● The new generation is usually smaller than the old one (1/3 of the old). ● The GC scans the younger generation, which does not paralyze the JVM. ● Who "survives" is copied to the Old generation and the space of the Young Generation is made available again. ● The discard does not remove from the memory yet, it just marks the memory as available. ● Although it is costly to copy an object to the old generation to another part of the Heap, few survive, so the cost is low. ● Also, copying fewer objects is still "cheaper" than removing objects. ● When Young is crowded, a minor collect runs. At this point objects are sent to the old generation.
  • 20. Garbage collector - generational copying ● Depending on the JVM, large objects have the behavior of already being copied to the Old generation; ● Generational copying copies the objects to the next in a clustered fashion, optimizing memory and ensuring that there is no memory fragmentation. ● It is possible to increase the proportion of the space allocated to Young Generation by the option -XX: NewRatio = 1 (50%). By default, 2/3 will be old and 1/3 will be young; by changing the value to 1, we will have 1/2 for each area.
  • 21. Garbage collector - Garbage First (G1) Although it is considered a generational algorithm, it does not separates the heap in two generations, but in many small regions. Dynamically, the G1 chooses some regions to be collected (which gives the logical sense of those regions to be a young gen).
  • 23. JIT Compiler (Just in time) or slow is your granny JIT compiles Java code in Runtime to improve the application performance. But I said before that JVM read Bytecode and runs it in a VM, right? The first JVMs were the same, but with each version, the JVM is increased and brought this new feature to the VM.
  • 24. JIT Compiler (Just in time) JIT has the ability to do optimization according to the use of the program and the current conditions. The so-called hotspots. What JIT does behind the scene? It compiles for native platform and runs native code optimizing the application running.
  • 25. Thanks =) By João Santana [email protected] github.com/jonss