SlideShare une entreprise Scribd logo
1  sur  16
PiergiorgioNiero My App is a Flash!
2 Speaker bio – PiergiorgioNieroTWITTER: @pigiuz Flash Platform developer since Macromedia® Flash 4 Software Engineer at Kaseya Corp( www.kaseya.com ) Co-Manager of The Flash Mind – AUG Milano Italy( www.theflashmind.com ) Casual tech blogger – FlashFuck.it( www.flashfuck.it )
Session Topic - Garbage Collector ,[object Object]
Stabilità,[object Object]
5 Cos’è e cosafail GC? ,[object Object]
Determina un cambiamentonettonello stile diprogrammazione:
Daterminazionedeterministica a una “non deterministic object finalization”Recupera le risorse allocate da questi oggetti Identifica oggetti non più in uso Libera le risorse e le rende disponibili
6 GC – Pros and Cons ,[object Object]
Impossibiledeterminarequandoil GC libererà la memorianè quantaualememorialibererà
Frammentazionedellamemoria e conseguentecalodi performances
“Embarassing pause”Piùdifficilecadere in erroridigestionedellamemoriaquali: DANGLING POINTERS DOUBLE FREE MEMORY LEAKS
7 Capireil GC – Determinare la raggiungibilitàdi un oggetto Un oggetto è raggiungibilequando a runtime c’èalmenounavariabileuntatoreche conduce ad esso Esistono due tipi di garbage: SINTATTIC GARBAGE: non esistepiù un puntatorevalidoall’oggetto (risolvibile a compile time) SEMANTIC GARBAGE: ipuntatorivalidi ad un oggettoesistonoall’internodi un bloccodicodice
8 Capireil GC – Reference Count Ognioggetto ha assegnato un contatoredeipuntatori ad esso L’oggettodiventa “garbaggiabile” quandoilsuocontatore è a zero: VANTAGGIO: è quantopiùprossimo ad unagestionedeterministicadellamemoria SVANTAGGIO: se due oggettisonocollegatitralororeciprocamente e non c’ènessunpuntatoreaccessibiledalprogramma per recuperarliilrisultato è un MEMORY LEAK A 1 B 1 LEAK! Singleton A 1
9 Capireil GC – Mark and Sweep Ognioggetto in memoria ha un flag “in use” assegnatodal GC Il GC iteraricorsivamentetuttiglioggetti e partendodainodi root e marca “in use” quelliraggiungibili Vieneeffettuataunasecondaiterazionedituttiglioggetti in memoria e vieneliberata la memoriadeglioggetti non “in use” To be collected! C 2 A 1 A 1 D 1 B 1 ROOT B 1 To be collected! E 0 ROOT
10 Capireil GC – Weak References ,[object Object],Weak Dictionary Normal Dictionary keys keys values values A 0 A 1 “ciao” “ciao” B 0 B 1 1 1 C 0 C 1 sprite sprite D 0 D 1 array array
11 Imboccareil GC – IDispose Il GC determinaglioggettidaliberaretramite reference count Creazionedi un destructor custom (rubiamodac++ e daBitmapData.dispose())

Contenu connexe

Dernier

Gabriele Mittica, CEO @Corley Cloud – “Come creare un’azienda “nativa in clou...
Gabriele Mittica, CEO @Corley Cloud – “Come creare un’azienda “nativa in clou...Gabriele Mittica, CEO @Corley Cloud – “Come creare un’azienda “nativa in clou...
Gabriele Mittica, CEO @Corley Cloud – “Come creare un’azienda “nativa in clou...Associazione Digital Days
 
Daniele Lunassi, CEO & Head of Design @Eye Studios – “Creare prodotti e servi...
Daniele Lunassi, CEO & Head of Design @Eye Studios – “Creare prodotti e servi...Daniele Lunassi, CEO & Head of Design @Eye Studios – “Creare prodotti e servi...
Daniele Lunassi, CEO & Head of Design @Eye Studios – “Creare prodotti e servi...Associazione Digital Days
 
Federico Bottino, Lead Venture Builder – “Riflessioni sull’Innovazione: La Cu...
Federico Bottino, Lead Venture Builder – “Riflessioni sull’Innovazione: La Cu...Federico Bottino, Lead Venture Builder – “Riflessioni sull’Innovazione: La Cu...
Federico Bottino, Lead Venture Builder – “Riflessioni sull’Innovazione: La Cu...Associazione Digital Days
 
Luigi Di Carlo, CEO & Founder @Evometrika srl – “Ruolo della computer vision ...
Luigi Di Carlo, CEO & Founder @Evometrika srl – “Ruolo della computer vision ...Luigi Di Carlo, CEO & Founder @Evometrika srl – “Ruolo della computer vision ...
Luigi Di Carlo, CEO & Founder @Evometrika srl – “Ruolo della computer vision ...Associazione Digital Days
 
Alessandro Nasi, COO @Djungle Studio – “Cosa delegheresti alla copia di te st...
Alessandro Nasi, COO @Djungle Studio – “Cosa delegheresti alla copia di te st...Alessandro Nasi, COO @Djungle Studio – “Cosa delegheresti alla copia di te st...
Alessandro Nasi, COO @Djungle Studio – “Cosa delegheresti alla copia di te st...Associazione Digital Days
 
Alessio Mazzotti, Aaron Brancotti; Writer, Screenwriter, Director, UX, Autore...
Alessio Mazzotti, Aaron Brancotti; Writer, Screenwriter, Director, UX, Autore...Alessio Mazzotti, Aaron Brancotti; Writer, Screenwriter, Director, UX, Autore...
Alessio Mazzotti, Aaron Brancotti; Writer, Screenwriter, Director, UX, Autore...Associazione Digital Days
 
Mael Chiabrera, Software Developer; Viola Bongini, Digital Experience Designe...
Mael Chiabrera, Software Developer; Viola Bongini, Digital Experience Designe...Mael Chiabrera, Software Developer; Viola Bongini, Digital Experience Designe...
Mael Chiabrera, Software Developer; Viola Bongini, Digital Experience Designe...Associazione Digital Days
 
Edoardo Di Pietro – “Virtual Influencer vs Umano: Rubiamo il lavoro all’AI”
Edoardo Di Pietro – “Virtual Influencer vs Umano: Rubiamo il lavoro all’AI”Edoardo Di Pietro – “Virtual Influencer vs Umano: Rubiamo il lavoro all’AI”
Edoardo Di Pietro – “Virtual Influencer vs Umano: Rubiamo il lavoro all’AI”Associazione Digital Days
 
Programma Biennale Tecnologia 2024 Torino
Programma Biennale Tecnologia 2024 TorinoProgramma Biennale Tecnologia 2024 Torino
Programma Biennale Tecnologia 2024 TorinoQuotidiano Piemontese
 

Dernier (9)

Gabriele Mittica, CEO @Corley Cloud – “Come creare un’azienda “nativa in clou...
Gabriele Mittica, CEO @Corley Cloud – “Come creare un’azienda “nativa in clou...Gabriele Mittica, CEO @Corley Cloud – “Come creare un’azienda “nativa in clou...
Gabriele Mittica, CEO @Corley Cloud – “Come creare un’azienda “nativa in clou...
 
Daniele Lunassi, CEO & Head of Design @Eye Studios – “Creare prodotti e servi...
Daniele Lunassi, CEO & Head of Design @Eye Studios – “Creare prodotti e servi...Daniele Lunassi, CEO & Head of Design @Eye Studios – “Creare prodotti e servi...
Daniele Lunassi, CEO & Head of Design @Eye Studios – “Creare prodotti e servi...
 
Federico Bottino, Lead Venture Builder – “Riflessioni sull’Innovazione: La Cu...
Federico Bottino, Lead Venture Builder – “Riflessioni sull’Innovazione: La Cu...Federico Bottino, Lead Venture Builder – “Riflessioni sull’Innovazione: La Cu...
Federico Bottino, Lead Venture Builder – “Riflessioni sull’Innovazione: La Cu...
 
Luigi Di Carlo, CEO & Founder @Evometrika srl – “Ruolo della computer vision ...
Luigi Di Carlo, CEO & Founder @Evometrika srl – “Ruolo della computer vision ...Luigi Di Carlo, CEO & Founder @Evometrika srl – “Ruolo della computer vision ...
Luigi Di Carlo, CEO & Founder @Evometrika srl – “Ruolo della computer vision ...
 
Alessandro Nasi, COO @Djungle Studio – “Cosa delegheresti alla copia di te st...
Alessandro Nasi, COO @Djungle Studio – “Cosa delegheresti alla copia di te st...Alessandro Nasi, COO @Djungle Studio – “Cosa delegheresti alla copia di te st...
Alessandro Nasi, COO @Djungle Studio – “Cosa delegheresti alla copia di te st...
 
Alessio Mazzotti, Aaron Brancotti; Writer, Screenwriter, Director, UX, Autore...
Alessio Mazzotti, Aaron Brancotti; Writer, Screenwriter, Director, UX, Autore...Alessio Mazzotti, Aaron Brancotti; Writer, Screenwriter, Director, UX, Autore...
Alessio Mazzotti, Aaron Brancotti; Writer, Screenwriter, Director, UX, Autore...
 
Mael Chiabrera, Software Developer; Viola Bongini, Digital Experience Designe...
Mael Chiabrera, Software Developer; Viola Bongini, Digital Experience Designe...Mael Chiabrera, Software Developer; Viola Bongini, Digital Experience Designe...
Mael Chiabrera, Software Developer; Viola Bongini, Digital Experience Designe...
 
Edoardo Di Pietro – “Virtual Influencer vs Umano: Rubiamo il lavoro all’AI”
Edoardo Di Pietro – “Virtual Influencer vs Umano: Rubiamo il lavoro all’AI”Edoardo Di Pietro – “Virtual Influencer vs Umano: Rubiamo il lavoro all’AI”
Edoardo Di Pietro – “Virtual Influencer vs Umano: Rubiamo il lavoro all’AI”
 
Programma Biennale Tecnologia 2024 Torino
Programma Biennale Tecnologia 2024 TorinoProgramma Biennale Tecnologia 2024 Torino
Programma Biennale Tecnologia 2024 Torino
 

En vedette

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

En vedette (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Flashcamp Milan 2011 - Garbage Collector in the Flash Platform

  • 2. 2 Speaker bio – PiergiorgioNieroTWITTER: @pigiuz Flash Platform developer since Macromedia® Flash 4 Software Engineer at Kaseya Corp( www.kaseya.com ) Co-Manager of The Flash Mind – AUG Milano Italy( www.theflashmind.com ) Casual tech blogger – FlashFuck.it( www.flashfuck.it )
  • 3.
  • 4.
  • 5.
  • 6. Determina un cambiamentonettonello stile diprogrammazione:
  • 7. Daterminazionedeterministica a una “non deterministic object finalization”Recupera le risorse allocate da questi oggetti Identifica oggetti non più in uso Libera le risorse e le rende disponibili
  • 8.
  • 9. Impossibiledeterminarequandoil GC libererà la memorianè quantaualememorialibererà
  • 11. “Embarassing pause”Piùdifficilecadere in erroridigestionedellamemoriaquali: DANGLING POINTERS DOUBLE FREE MEMORY LEAKS
  • 12. 7 Capireil GC – Determinare la raggiungibilitàdi un oggetto Un oggetto è raggiungibilequando a runtime c’èalmenounavariabileuntatoreche conduce ad esso Esistono due tipi di garbage: SINTATTIC GARBAGE: non esistepiù un puntatorevalidoall’oggetto (risolvibile a compile time) SEMANTIC GARBAGE: ipuntatorivalidi ad un oggettoesistonoall’internodi un bloccodicodice
  • 13. 8 Capireil GC – Reference Count Ognioggetto ha assegnato un contatoredeipuntatori ad esso L’oggettodiventa “garbaggiabile” quandoilsuocontatore è a zero: VANTAGGIO: è quantopiùprossimo ad unagestionedeterministicadellamemoria SVANTAGGIO: se due oggettisonocollegatitralororeciprocamente e non c’ènessunpuntatoreaccessibiledalprogramma per recuperarliilrisultato è un MEMORY LEAK A 1 B 1 LEAK! Singleton A 1
  • 14. 9 Capireil GC – Mark and Sweep Ognioggetto in memoria ha un flag “in use” assegnatodal GC Il GC iteraricorsivamentetuttiglioggetti e partendodainodi root e marca “in use” quelliraggiungibili Vieneeffettuataunasecondaiterazionedituttiglioggetti in memoria e vieneliberata la memoriadeglioggetti non “in use” To be collected! C 2 A 1 A 1 D 1 B 1 ROOT B 1 To be collected! E 0 ROOT
  • 15.
  • 16. 11 Imboccareil GC – IDispose Il GC determinaglioggettidaliberaretramite reference count Creazionedi un destructor custom (rubiamodac++ e daBitmapData.dispose())
  • 17. 12 Alleggerireil GC – Blitting Il GC devepercorrerericorsivamentetuttiglioggettipartendodalle root Lo stage del nostroswf è una root sullaqualepoggia la display list Diminuiamonotevolmenteilnumerodioggettidapercorrere: Riconduciamo la display list in un unico Bitmap ( display list != root ) Raggruppiamoglioggettisorgente ( sprite sheet ) Mario Sprite Sheet Super Mario Bros Level - Blitted
  • 18. 13 Non utilizzareil GC – Memory Pool Il GC arrestailsistemamentrelibera la memoria Il GC determinaglioggettidaliberaretramite reference count Creazioneglioggettitramite un object pool Riduciamo al minimoglioggettidariciclarestabilizzandol’usodellamemoria Pre-allocazionedeglioggetti Riduciamo al minimo la creazionedinuovioggettiriutilizzandosempreglistessi