SlideShare a Scribd company logo
Introducci´on al GC en Java - Porqu´e mis
aplicaciones explotan
V´ıctor Orozco - @tuxtor
10 de mayo de 2018
GuateJUG
1
V´ıctor Orozco
• Developer (JVM/Open
Source Advocate)
• JUG Leader
• Consultor independiente
• Profesor universitario
• @tuxtor
• http://vorozco.com
• http://tuxtor.shekalug.org
2
TLDR
Explosi´on
• Mala selecci´on de tipos de dato
• Muchas variables y referencias (memory leak)
• Algoritmos innecesariamente complejos
• Muchas apps y poca memoria
3
Memoria en Java
Stack vs heap
Figura 1: Stack y Heap
4
Stack vs heap
Figura 2: Java main thread
5
Mark and sweep
Figura 3: Mark and sweep, Credits: https://plumbr.io
6
Mark and sweep
Figura 4: Mark and sweep - Mark, Credits: https://plumbr.io
Generalmente DFS
7
Mark and sweep
Figura 5: Mark and sweep - sweep, Credits: https://plumbr.io
8
Mark and sweep
Figura 6: Mark - sweep, Credits: https://plumbr.io
9
Mark - sweep - compact
Figura 7: Mark - sweep - compact, Credits: https://plumbr.io
10
Mark and copy
Figura 8: Mark and copy, Credits: https://plumbr.io
11
Demo 0 - Generaci´on de objetos
//...
Stream <Integer > nums = Stream.iterate (1, n -> n + 1);
nums.forEach(num -> {
System.out.println(num);
try{Thread.sleep (10);}
catch( InterruptedException ex){}
}
);
//...
12
Generational garbage collectors
Generational GC(HotSpot)
Figura 9: Generational GC, Credits: Oracle
13
Generational GC(HotSpot)
Figura 10: Generational GC, Credits: Oracle
14
Generational GC(HotSpot)
Figura 11: Generational GC, Credits: Oracle
15
Generational GC(HotSpot)
Figura 12: Generational GC, Credits: Oracle
16
Generational GC(HotSpot)
Figura 13: Generational GC, Credits: Oracle
17
Generational GC(HotSpot)
Figura 14: Generational GC, Credits: Oracle
18
Generational GC(HotSpot)
Figura 15: Generational GC, Credits: Oracle
19
Demo 1 - GC Generacional
//...
Stream <Integer > nums = Stream.iterate (1, n -> n + 1);
var numeros = new ArrayList <Integer >();
nums.forEach(num -> {
System.out.println(num);
numeros.add(num);
});
//...
java -XX:+UseSerialGC DemoMemoriaGenerations
20
GC en HotSpot
Recolectores de basura
• Serial GC para Young y Old generations
• Parallel GC para Young y Old generations
• Parallel New para Young + Concurrent Mark and Sweep
(CMS) para Old Generation
• G1GC, para Young y Old generations
21
SerialGC
• Young: Mark-Copy
• Old: Mark-Sweep-Compact
• java − XX : +UseSerialGCcom.nabenik.MyExecClass
22
ParallelGC
• Young: Mark-Copy
• Old: Mark-Sweep-Compact
• Stop-the-world en ambas regiones
• java − XX : +UseParallelGCcom.nabenik.MyExecClass
23
CMS
• Young: Mark-Copy - Stop the world
• Old: (Mostly )Concurrent Mark Sweep (Paralelo)
• java − XX :
+UseConcMarkSweepGCcom.nabenik.MyExecClass
24
Como luchar CONTRA un Garbage
Collector
Demo 1 - Referencias + Mal tipo de dato
//...
var lasReferencias = new ArrayList <String >();
Stream <Integer > numeros = Stream.iterate (1, n -> ++n);
numeros.forEach(n -> {
lasReferencias.add(n + "");
if( lasReferencias.size () % 10 _000_000 == 0){
System.out.println(n);
try{ Thread.sleep (3000); }
catch( InterruptedException e){}
}
});
}
//...
25
Demo 2 - Referencias
//...
var lasReferencias = new ArrayList <Integer >();
var numeros = IntStream.iterate (1, n -> ++n);
numeros.forEach(n -> {
lasReferencias.add(n);
if( lasReferencias.size () % 10 _000_000 == 0){
System.out.println(n);
try{ Thread.sleep (3000); }
catch( InterruptedException e){}
}
});
//...
26
Demo 3 - Concatenaci´on de String
//...
static String texto = "";
public static void main(String [] args ){
var numeros = IntStream.iterate (1, t -> ++t);
numeros.forEach(n -> {
texto += " " + n;
if(n % 10 _000 == 0) System.out.println(n);
});
}
//...
27
Demo 4 - StringBuffer
//...
static StringBuilder texto = new StringBuilder("");
public static void main(String [] args ){
var numeros = IntStream.iterate (1, t -> ++t);
numeros.forEach(n -> {
texto.append(" ");
texto.append(n);
if(n % 10 _000 == 0) System.out.println(n);
});
}
//...
28
Complejidad de algoritmos
Complejidad
Complejidad = Cantidad de pasos para realizar una tarea
Figura 16: Complejidad computacional
Tambi´en conocido como ”programar bien”:O
29
Fibonacci
Figura 17: Sucesi´on Fibonacci
30
Demo 5 - Mal Fibonacci
//...
public static long doFibonacci(int n) {
if (n <= 1)
return n;
else
return doFibonacci(n-1) + doFibonacci(n -2);
}
//...
31
Demo 6 - Buen Fibonacci
//...
public static long doFibonacci(int n) {
long a=0, b=1, c=0;
for(int i = 0 ; i < n; i++){
c = a + b;
a = b;
b = c;
}
return c;
}
//...
32
Gracias
• me@vorozco.com
• http://vorozco.com
• http://github.com/tuxtor/slides
This work is licensed under a Creative Commons
Attribution-ShareAlike 3.0 Guatemala License.
33

More Related Content

What's hot

Explore the history, versions and features of Java- a report by Pranav Mishra
Explore the history, versions and features of Java- a report by Pranav MishraExplore the history, versions and features of Java- a report by Pranav Mishra
Explore the history, versions and features of Java- a report by Pranav Mishra
Sopra Steria India
 
Design Patterns para Microsserviços com MicroProfile
 Design Patterns para Microsserviços com MicroProfile Design Patterns para Microsserviços com MicroProfile
Design Patterns para Microsserviços com MicroProfile
Víctor Leonel Orozco López
 
Embedded systems
Embedded systems Embedded systems
Embedded systems
Katy Anton
 
Rx java in action
Rx java in actionRx java in action
Rx java in action
Pratama Nur Wijaya
 
jcmd #javacasual
jcmd #javacasualjcmd #javacasual
jcmd #javacasual
Yuji Kubota
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
Rick Warren
 
Dropwizard
DropwizardDropwizard
Dropwizard
Tetiana Saputo
 
7 jvm-arguments-v1
7 jvm-arguments-v17 jvm-arguments-v1
7 jvm-arguments-v1
Tier1 app
 
Introduction to Retrofit and RxJava
Introduction to Retrofit and RxJavaIntroduction to Retrofit and RxJava
Introduction to Retrofit and RxJava
Fabio Collini
 
How to cook lettuce @Java casual
How to cook lettuce @Java casualHow to cook lettuce @Java casual
How to cook lettuce @Java casual
Go Hagiwara
 
Vert.x v3 - high performance polyglot application toolkit
Vert.x v3 - high performance  polyglot application toolkitVert.x v3 - high performance  polyglot application toolkit
Vert.x v3 - high performance polyglot application toolkit
Sages
 
Monitor your CentOS stack with Prometheus
Monitor your CentOS stack with PrometheusMonitor your CentOS stack with Prometheus
Monitor your CentOS stack with Prometheus
Julien Pivotto
 
[231] the simplicity of cluster apps with circuit
[231] the simplicity of cluster apps with circuit[231] the simplicity of cluster apps with circuit
[231] the simplicity of cluster apps with circuit
NAVER D2
 
Micro-metrics to forecast performance tsunamis
Micro-metrics to forecast performance tsunamisMicro-metrics to forecast performance tsunamis
Micro-metrics to forecast performance tsunamis
Tier1 app
 
16 artifacts to capture when there is a production problem
16 artifacts to capture when there is a production problem16 artifacts to capture when there is a production problem
16 artifacts to capture when there is a production problem
Tier1 app
 
Lets crash-applications
Lets crash-applicationsLets crash-applications
Lets crash-applications
Tier1 app
 
Lets crash-applications
Lets crash-applicationsLets crash-applications
Lets crash-applications
Tier1 app
 
Java On Speed
Java On SpeedJava On Speed
Java On Speed
Arto Santala
 
Supercharged java 8 : with cyclops-react
Supercharged java 8 : with cyclops-reactSupercharged java 8 : with cyclops-react
Supercharged java 8 : with cyclops-react
John McClean
 
Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~
Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~
Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~
ikikko
 

What's hot (20)

Explore the history, versions and features of Java- a report by Pranav Mishra
Explore the history, versions and features of Java- a report by Pranav MishraExplore the history, versions and features of Java- a report by Pranav Mishra
Explore the history, versions and features of Java- a report by Pranav Mishra
 
Design Patterns para Microsserviços com MicroProfile
 Design Patterns para Microsserviços com MicroProfile Design Patterns para Microsserviços com MicroProfile
Design Patterns para Microsserviços com MicroProfile
 
Embedded systems
Embedded systems Embedded systems
Embedded systems
 
Rx java in action
Rx java in actionRx java in action
Rx java in action
 
jcmd #javacasual
jcmd #javacasualjcmd #javacasual
jcmd #javacasual
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
 
Dropwizard
DropwizardDropwizard
Dropwizard
 
7 jvm-arguments-v1
7 jvm-arguments-v17 jvm-arguments-v1
7 jvm-arguments-v1
 
Introduction to Retrofit and RxJava
Introduction to Retrofit and RxJavaIntroduction to Retrofit and RxJava
Introduction to Retrofit and RxJava
 
How to cook lettuce @Java casual
How to cook lettuce @Java casualHow to cook lettuce @Java casual
How to cook lettuce @Java casual
 
Vert.x v3 - high performance polyglot application toolkit
Vert.x v3 - high performance  polyglot application toolkitVert.x v3 - high performance  polyglot application toolkit
Vert.x v3 - high performance polyglot application toolkit
 
Monitor your CentOS stack with Prometheus
Monitor your CentOS stack with PrometheusMonitor your CentOS stack with Prometheus
Monitor your CentOS stack with Prometheus
 
[231] the simplicity of cluster apps with circuit
[231] the simplicity of cluster apps with circuit[231] the simplicity of cluster apps with circuit
[231] the simplicity of cluster apps with circuit
 
Micro-metrics to forecast performance tsunamis
Micro-metrics to forecast performance tsunamisMicro-metrics to forecast performance tsunamis
Micro-metrics to forecast performance tsunamis
 
16 artifacts to capture when there is a production problem
16 artifacts to capture when there is a production problem16 artifacts to capture when there is a production problem
16 artifacts to capture when there is a production problem
 
Lets crash-applications
Lets crash-applicationsLets crash-applications
Lets crash-applications
 
Lets crash-applications
Lets crash-applicationsLets crash-applications
Lets crash-applications
 
Java On Speed
Java On SpeedJava On Speed
Java On Speed
 
Supercharged java 8 : with cyclops-react
Supercharged java 8 : with cyclops-reactSupercharged java 8 : with cyclops-react
Supercharged java 8 : with cyclops-react
 
Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~
Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~
Jenkins 2を使った究極のpipeline ~ 明日もう一度来てください、本物のpipelineをお見せしますよ ~
 

Similar to Principios básicos de Garbage Collector en Java

Solr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approachSolr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approach
Alexandre Rafalovitch
 
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Lucidworks
 
JRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the CloudJRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the Cloud
Hiro Asari
 
Microsoft Power Point Best Practices For Scaling Heavily Adopted And Concur...
Microsoft Power Point   Best Practices For Scaling Heavily Adopted And Concur...Microsoft Power Point   Best Practices For Scaling Heavily Adopted And Concur...
Microsoft Power Point Best Practices For Scaling Heavily Adopted And Concur...
Steve Feldman
 
Gopher in performance_tales_ms_go_cracow
Gopher in performance_tales_ms_go_cracowGopher in performance_tales_ms_go_cracow
Gopher in performance_tales_ms_go_cracow
MateuszSzczyrzyca
 
Grow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM StackGrow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM Stack
KeitaSugiyama1
 
Heap & thread dump
Heap & thread dumpHeap & thread dump
Heap & thread dump
Nishit Charania
 
Microservices with Micronaut
Microservices with MicronautMicroservices with Micronaut
Microservices with Micronaut
QAware GmbH
 
Fight with Metaspace OOM
Fight with Metaspace OOMFight with Metaspace OOM
Fight with Metaspace OOM
Leon Chen
 
Jose Selvi - Side-Channels Uncovered [rootedvlc2018]
Jose Selvi - Side-Channels Uncovered [rootedvlc2018]Jose Selvi - Side-Channels Uncovered [rootedvlc2018]
Jose Selvi - Side-Channels Uncovered [rootedvlc2018]
RootedCON
 
Hadoop cluster performance profiler
Hadoop cluster performance profilerHadoop cluster performance profiler
Hadoop cluster performance profiler
Ihor Bobak
 
iSoligorsk #3 2013
iSoligorsk #3 2013iSoligorsk #3 2013
iSoligorsk #3 2013
Friedrich Boeckh
 
Microservices with Micronaut
Microservices with MicronautMicroservices with Micronaut
Microservices with Micronaut
QAware GmbH
 
Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨
flyinweb
 
Optimal Strategies for Large Scale Batch ETL Jobs with Emma Tang
Optimal Strategies for Large Scale Batch ETL Jobs with Emma TangOptimal Strategies for Large Scale Batch ETL Jobs with Emma Tang
Optimal Strategies for Large Scale Batch ETL Jobs with Emma Tang
Databricks
 
Optimal Strategies for Large-Scale Batch ETL Jobs
Optimal Strategies for Large-Scale Batch ETL JobsOptimal Strategies for Large-Scale Batch ETL Jobs
Optimal Strategies for Large-Scale Batch ETL Jobs
Emma Tang
 
Jvm problem diagnostics
Jvm problem diagnosticsJvm problem diagnostics
Jvm problem diagnostics
Danijel Mitar
 
Are you ready for cloud-native java JavaCro2019
Are you ready for cloud-native java JavaCro2019Are you ready for cloud-native java JavaCro2019
Are you ready for cloud-native java JavaCro2019
Jamie Coleman
 
Profiling your Java Application
Profiling your Java ApplicationProfiling your Java Application
Profiling your Java Application
Victor Rentea
 
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
chen yuki
 

Similar to Principios básicos de Garbage Collector en Java (20)

Solr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approachSolr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approach
 
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
 
JRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the CloudJRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the Cloud
 
Microsoft Power Point Best Practices For Scaling Heavily Adopted And Concur...
Microsoft Power Point   Best Practices For Scaling Heavily Adopted And Concur...Microsoft Power Point   Best Practices For Scaling Heavily Adopted And Concur...
Microsoft Power Point Best Practices For Scaling Heavily Adopted And Concur...
 
Gopher in performance_tales_ms_go_cracow
Gopher in performance_tales_ms_go_cracowGopher in performance_tales_ms_go_cracow
Gopher in performance_tales_ms_go_cracow
 
Grow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM StackGrow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM Stack
 
Heap & thread dump
Heap & thread dumpHeap & thread dump
Heap & thread dump
 
Microservices with Micronaut
Microservices with MicronautMicroservices with Micronaut
Microservices with Micronaut
 
Fight with Metaspace OOM
Fight with Metaspace OOMFight with Metaspace OOM
Fight with Metaspace OOM
 
Jose Selvi - Side-Channels Uncovered [rootedvlc2018]
Jose Selvi - Side-Channels Uncovered [rootedvlc2018]Jose Selvi - Side-Channels Uncovered [rootedvlc2018]
Jose Selvi - Side-Channels Uncovered [rootedvlc2018]
 
Hadoop cluster performance profiler
Hadoop cluster performance profilerHadoop cluster performance profiler
Hadoop cluster performance profiler
 
iSoligorsk #3 2013
iSoligorsk #3 2013iSoligorsk #3 2013
iSoligorsk #3 2013
 
Microservices with Micronaut
Microservices with MicronautMicroservices with Micronaut
Microservices with Micronaut
 
Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨
 
Optimal Strategies for Large Scale Batch ETL Jobs with Emma Tang
Optimal Strategies for Large Scale Batch ETL Jobs with Emma TangOptimal Strategies for Large Scale Batch ETL Jobs with Emma Tang
Optimal Strategies for Large Scale Batch ETL Jobs with Emma Tang
 
Optimal Strategies for Large-Scale Batch ETL Jobs
Optimal Strategies for Large-Scale Batch ETL JobsOptimal Strategies for Large-Scale Batch ETL Jobs
Optimal Strategies for Large-Scale Batch ETL Jobs
 
Jvm problem diagnostics
Jvm problem diagnosticsJvm problem diagnostics
Jvm problem diagnostics
 
Are you ready for cloud-native java JavaCro2019
Are you ready for cloud-native java JavaCro2019Are you ready for cloud-native java JavaCro2019
Are you ready for cloud-native java JavaCro2019
 
Profiling your Java Application
Profiling your Java ApplicationProfiling your Java Application
Profiling your Java Application
 
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
 

More from Víctor Leonel Orozco López

Introducción al análisis de datos
Introducción al análisis de datosIntroducción al análisis de datos
Introducción al análisis de datos
Víctor Leonel Orozco López
 
From traditional to GitOps
From traditional to GitOpsFrom traditional to GitOps
From traditional to GitOps
Víctor Leonel Orozco López
 
Iniciando microservicios reales con JakartaEE/MicroProfile y arquetipos de Maven
Iniciando microservicios reales con JakartaEE/MicroProfile y arquetipos de MavenIniciando microservicios reales con JakartaEE/MicroProfile y arquetipos de Maven
Iniciando microservicios reales con JakartaEE/MicroProfile y arquetipos de Maven
Víctor Leonel Orozco López
 
Desde la TV, hasta la nube, el ecosistema de Java en 26 años
Desde la TV, hasta la nube, el ecosistema de Java en 26 añosDesde la TV, hasta la nube, el ecosistema de Java en 26 años
Desde la TV, hasta la nube, el ecosistema de Java en 26 años
Víctor Leonel Orozco López
 
Bootstraping real world Jakarta EE/MicroProfile microservices with Maven Arch...
Bootstraping real world Jakarta EE/MicroProfile microservices with Maven Arch...Bootstraping real world Jakarta EE/MicroProfile microservices with Maven Arch...
Bootstraping real world Jakarta EE/MicroProfile microservices with Maven Arch...
Víctor Leonel Orozco López
 
Tolerancia a fallas, service mesh y chassis
Tolerancia a fallas, service mesh y chassisTolerancia a fallas, service mesh y chassis
Tolerancia a fallas, service mesh y chassis
Víctor Leonel Orozco López
 
Explorando los objetos centrales de Kubernetes con Oracle Cloud
Explorando los objetos centrales de Kubernetes con Oracle CloudExplorando los objetos centrales de Kubernetes con Oracle Cloud
Explorando los objetos centrales de Kubernetes con Oracle Cloud
Víctor Leonel Orozco López
 
Introducción a GraalVM Native para aplicaciones JVM
Introducción a GraalVM Native para aplicaciones JVMIntroducción a GraalVM Native para aplicaciones JVM
Introducción a GraalVM Native para aplicaciones JVM
Víctor Leonel Orozco López
 
Desarrollo moderno con DevOps y Cloud Native
Desarrollo moderno con DevOps y Cloud NativeDesarrollo moderno con DevOps y Cloud Native
Desarrollo moderno con DevOps y Cloud Native
Víctor Leonel Orozco López
 
Gestión de proyectos con Maven
Gestión de proyectos con MavenGestión de proyectos con Maven
Gestión de proyectos con Maven
Víctor Leonel Orozco López
 
MicroProfile benefits for your monolithic applications
MicroProfile benefits for your monolithic applicationsMicroProfile benefits for your monolithic applications
MicroProfile benefits for your monolithic applications
Víctor Leonel Orozco López
 
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Víctor Leonel Orozco López
 
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Víctor Leonel Orozco López
 
Consejos y el camino del desarrollador de software
Consejos y el camino del desarrollador de softwareConsejos y el camino del desarrollador de software
Consejos y el camino del desarrollador de software
Víctor Leonel Orozco López
 
Seguridad de aplicaciones Java/JakartaEE con OWASP Top 10
Seguridad de aplicaciones Java/JakartaEE con OWASP Top 10Seguridad de aplicaciones Java/JakartaEE con OWASP Top 10
Seguridad de aplicaciones Java/JakartaEE con OWASP Top 10
Víctor Leonel Orozco López
 
Introducción a Kotlin para desarrolladores Java
Introducción a Kotlin para desarrolladores JavaIntroducción a Kotlin para desarrolladores Java
Introducción a Kotlin para desarrolladores Java
Víctor Leonel Orozco López
 
Programación con ECMA6 y TypeScript
Programación con ECMA6 y TypeScriptProgramación con ECMA6 y TypeScript
Programación con ECMA6 y TypeScript
Víctor Leonel Orozco López
 
Empaquetando aplicaciones Java con Docker y Kubernetes
Empaquetando aplicaciones Java con Docker y KubernetesEmpaquetando aplicaciones Java con Docker y Kubernetes
Empaquetando aplicaciones Java con Docker y Kubernetes
Víctor Leonel Orozco López
 
MicroProfile benefits for monolitic applications
MicroProfile benefits for monolitic applicationsMicroProfile benefits for monolitic applications
MicroProfile benefits for monolitic applications
Víctor Leonel Orozco López
 
Microservicios con Jakarta EE y Eclipse MicroProfile
Microservicios con Jakarta EE y Eclipse MicroProfileMicroservicios con Jakarta EE y Eclipse MicroProfile
Microservicios con Jakarta EE y Eclipse MicroProfile
Víctor Leonel Orozco López
 

More from Víctor Leonel Orozco López (20)

Introducción al análisis de datos
Introducción al análisis de datosIntroducción al análisis de datos
Introducción al análisis de datos
 
From traditional to GitOps
From traditional to GitOpsFrom traditional to GitOps
From traditional to GitOps
 
Iniciando microservicios reales con JakartaEE/MicroProfile y arquetipos de Maven
Iniciando microservicios reales con JakartaEE/MicroProfile y arquetipos de MavenIniciando microservicios reales con JakartaEE/MicroProfile y arquetipos de Maven
Iniciando microservicios reales con JakartaEE/MicroProfile y arquetipos de Maven
 
Desde la TV, hasta la nube, el ecosistema de Java en 26 años
Desde la TV, hasta la nube, el ecosistema de Java en 26 añosDesde la TV, hasta la nube, el ecosistema de Java en 26 años
Desde la TV, hasta la nube, el ecosistema de Java en 26 años
 
Bootstraping real world Jakarta EE/MicroProfile microservices with Maven Arch...
Bootstraping real world Jakarta EE/MicroProfile microservices with Maven Arch...Bootstraping real world Jakarta EE/MicroProfile microservices with Maven Arch...
Bootstraping real world Jakarta EE/MicroProfile microservices with Maven Arch...
 
Tolerancia a fallas, service mesh y chassis
Tolerancia a fallas, service mesh y chassisTolerancia a fallas, service mesh y chassis
Tolerancia a fallas, service mesh y chassis
 
Explorando los objetos centrales de Kubernetes con Oracle Cloud
Explorando los objetos centrales de Kubernetes con Oracle CloudExplorando los objetos centrales de Kubernetes con Oracle Cloud
Explorando los objetos centrales de Kubernetes con Oracle Cloud
 
Introducción a GraalVM Native para aplicaciones JVM
Introducción a GraalVM Native para aplicaciones JVMIntroducción a GraalVM Native para aplicaciones JVM
Introducción a GraalVM Native para aplicaciones JVM
 
Desarrollo moderno con DevOps y Cloud Native
Desarrollo moderno con DevOps y Cloud NativeDesarrollo moderno con DevOps y Cloud Native
Desarrollo moderno con DevOps y Cloud Native
 
Gestión de proyectos con Maven
Gestión de proyectos con MavenGestión de proyectos con Maven
Gestión de proyectos con Maven
 
MicroProfile benefits for your monolithic applications
MicroProfile benefits for your monolithic applicationsMicroProfile benefits for your monolithic applications
MicroProfile benefits for your monolithic applications
 
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
 
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
 
Consejos y el camino del desarrollador de software
Consejos y el camino del desarrollador de softwareConsejos y el camino del desarrollador de software
Consejos y el camino del desarrollador de software
 
Seguridad de aplicaciones Java/JakartaEE con OWASP Top 10
Seguridad de aplicaciones Java/JakartaEE con OWASP Top 10Seguridad de aplicaciones Java/JakartaEE con OWASP Top 10
Seguridad de aplicaciones Java/JakartaEE con OWASP Top 10
 
Introducción a Kotlin para desarrolladores Java
Introducción a Kotlin para desarrolladores JavaIntroducción a Kotlin para desarrolladores Java
Introducción a Kotlin para desarrolladores Java
 
Programación con ECMA6 y TypeScript
Programación con ECMA6 y TypeScriptProgramación con ECMA6 y TypeScript
Programación con ECMA6 y TypeScript
 
Empaquetando aplicaciones Java con Docker y Kubernetes
Empaquetando aplicaciones Java con Docker y KubernetesEmpaquetando aplicaciones Java con Docker y Kubernetes
Empaquetando aplicaciones Java con Docker y Kubernetes
 
MicroProfile benefits for monolitic applications
MicroProfile benefits for monolitic applicationsMicroProfile benefits for monolitic applications
MicroProfile benefits for monolitic applications
 
Microservicios con Jakarta EE y Eclipse MicroProfile
Microservicios con Jakarta EE y Eclipse MicroProfileMicroservicios con Jakarta EE y Eclipse MicroProfile
Microservicios con Jakarta EE y Eclipse MicroProfile
 

Recently uploaded

“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
Edge AI and Vision Alliance
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Neo4j
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 

Recently uploaded (20)

“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
Artificial Intelligence and Electronic Warfare
Artificial Intelligence and Electronic WarfareArtificial Intelligence and Electronic Warfare
Artificial Intelligence and Electronic Warfare
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 

Principios básicos de Garbage Collector en Java

  • 1. Introducci´on al GC en Java - Porqu´e mis aplicaciones explotan V´ıctor Orozco - @tuxtor 10 de mayo de 2018 GuateJUG 1
  • 2. V´ıctor Orozco • Developer (JVM/Open Source Advocate) • JUG Leader • Consultor independiente • Profesor universitario • @tuxtor • http://vorozco.com • http://tuxtor.shekalug.org 2
  • 3. TLDR Explosi´on • Mala selecci´on de tipos de dato • Muchas variables y referencias (memory leak) • Algoritmos innecesariamente complejos • Muchas apps y poca memoria 3
  • 5. Stack vs heap Figura 1: Stack y Heap 4
  • 6. Stack vs heap Figura 2: Java main thread 5
  • 7. Mark and sweep Figura 3: Mark and sweep, Credits: https://plumbr.io 6
  • 8. Mark and sweep Figura 4: Mark and sweep - Mark, Credits: https://plumbr.io Generalmente DFS 7
  • 9. Mark and sweep Figura 5: Mark and sweep - sweep, Credits: https://plumbr.io 8
  • 10. Mark and sweep Figura 6: Mark - sweep, Credits: https://plumbr.io 9
  • 11. Mark - sweep - compact Figura 7: Mark - sweep - compact, Credits: https://plumbr.io 10
  • 12. Mark and copy Figura 8: Mark and copy, Credits: https://plumbr.io 11
  • 13. Demo 0 - Generaci´on de objetos //... Stream <Integer > nums = Stream.iterate (1, n -> n + 1); nums.forEach(num -> { System.out.println(num); try{Thread.sleep (10);} catch( InterruptedException ex){} } ); //... 12
  • 15. Generational GC(HotSpot) Figura 9: Generational GC, Credits: Oracle 13
  • 16. Generational GC(HotSpot) Figura 10: Generational GC, Credits: Oracle 14
  • 17. Generational GC(HotSpot) Figura 11: Generational GC, Credits: Oracle 15
  • 18. Generational GC(HotSpot) Figura 12: Generational GC, Credits: Oracle 16
  • 19. Generational GC(HotSpot) Figura 13: Generational GC, Credits: Oracle 17
  • 20. Generational GC(HotSpot) Figura 14: Generational GC, Credits: Oracle 18
  • 21. Generational GC(HotSpot) Figura 15: Generational GC, Credits: Oracle 19
  • 22. Demo 1 - GC Generacional //... Stream <Integer > nums = Stream.iterate (1, n -> n + 1); var numeros = new ArrayList <Integer >(); nums.forEach(num -> { System.out.println(num); numeros.add(num); }); //... java -XX:+UseSerialGC DemoMemoriaGenerations 20
  • 24. Recolectores de basura • Serial GC para Young y Old generations • Parallel GC para Young y Old generations • Parallel New para Young + Concurrent Mark and Sweep (CMS) para Old Generation • G1GC, para Young y Old generations 21
  • 25. SerialGC • Young: Mark-Copy • Old: Mark-Sweep-Compact • java − XX : +UseSerialGCcom.nabenik.MyExecClass 22
  • 26. ParallelGC • Young: Mark-Copy • Old: Mark-Sweep-Compact • Stop-the-world en ambas regiones • java − XX : +UseParallelGCcom.nabenik.MyExecClass 23
  • 27. CMS • Young: Mark-Copy - Stop the world • Old: (Mostly )Concurrent Mark Sweep (Paralelo) • java − XX : +UseConcMarkSweepGCcom.nabenik.MyExecClass 24
  • 28. Como luchar CONTRA un Garbage Collector
  • 29. Demo 1 - Referencias + Mal tipo de dato //... var lasReferencias = new ArrayList <String >(); Stream <Integer > numeros = Stream.iterate (1, n -> ++n); numeros.forEach(n -> { lasReferencias.add(n + ""); if( lasReferencias.size () % 10 _000_000 == 0){ System.out.println(n); try{ Thread.sleep (3000); } catch( InterruptedException e){} } }); } //... 25
  • 30. Demo 2 - Referencias //... var lasReferencias = new ArrayList <Integer >(); var numeros = IntStream.iterate (1, n -> ++n); numeros.forEach(n -> { lasReferencias.add(n); if( lasReferencias.size () % 10 _000_000 == 0){ System.out.println(n); try{ Thread.sleep (3000); } catch( InterruptedException e){} } }); //... 26
  • 31. Demo 3 - Concatenaci´on de String //... static String texto = ""; public static void main(String [] args ){ var numeros = IntStream.iterate (1, t -> ++t); numeros.forEach(n -> { texto += " " + n; if(n % 10 _000 == 0) System.out.println(n); }); } //... 27
  • 32. Demo 4 - StringBuffer //... static StringBuilder texto = new StringBuilder(""); public static void main(String [] args ){ var numeros = IntStream.iterate (1, t -> ++t); numeros.forEach(n -> { texto.append(" "); texto.append(n); if(n % 10 _000 == 0) System.out.println(n); }); } //... 28
  • 34. Complejidad Complejidad = Cantidad de pasos para realizar una tarea Figura 16: Complejidad computacional Tambi´en conocido como ”programar bien”:O 29
  • 36. Demo 5 - Mal Fibonacci //... public static long doFibonacci(int n) { if (n <= 1) return n; else return doFibonacci(n-1) + doFibonacci(n -2); } //... 31
  • 37. Demo 6 - Buen Fibonacci //... public static long doFibonacci(int n) { long a=0, b=1, c=0; for(int i = 0 ; i < n; i++){ c = a + b; a = b; b = c; } return c; } //... 32
  • 38. Gracias • me@vorozco.com • http://vorozco.com • http://github.com/tuxtor/slides This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Guatemala License. 33