SlideShare ist ein Scribd-Unternehmen logo
1 von 63
Downloaden Sie, um offline zu lesen
Rodrigo Kumpera
Runtime Engineer
Xamarin
kumpera@xamarin.com
Advanced
Memory Management
on
iOS and Android
Mark Probst
Runtime Engineer
Xamarin
mark@xamarin.com
Advanced
Memory Management
on
iOS and Android
What a Garbage Collector Does
• Gives you memory for your objects
• Computes which objects are reachable
• Gets rid of the rest (= garbage)
h"p://www.flickr.com/photos/tweng/2235972313/
object reference
object with
reference
one object ... … referencing ... … another
Basic Garbage Collection
Root
Garbage Collection
Root
Garbage Collection
Root
Garbage Collection
Root
Garbage Collection
Root
Garbage Collection
Root
Garbage Collection
Root
Garbage Collection
Root
Garbage Collection
Two Generations
• Generational hypothesis
Most objects die young
• Nursery
Where (small) objects are born
• Major
Where they are copied to when they mature
• Large Object Space
Part of the major generation, objects > 8Kb
Typically large arrays
Stop-the-World
• Nursery collection pauses are short
• Major collection pauses can take a long time
• All threads registered with the runtime are stopped
That includes the main run loop thread
• iOS animations continue to run in a separate process
Common Issues
• Let’s examine three common issues
• Given a trivial piece code
Find the issue
Understand the problem
Learn how to fix it
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
iOS Puzzle 1
public	
  override	
  void	
  ViewDidLoad	
  ()
{
	
   var	
  imageView	
  =	
  new	
  UIImageView	
  (IMG_VIEW_POSITION);
	
   var	
  image	
  =	
  UIImage.FromBundle	
  ("grumpy-­‐cat.jpg");
	
   imageView.Image	
  =	
  image;
	
   View.Add	
  (imageView);
	
  
	
   var	
  button	
  =	
  UIButton.FromType	
  (UIButtonType.RoundedRect);
	
   button.Frame	
  =	
  BUTTON_POSITION;
	
   View.Add	
  (button);
	
  
	
   button.TouchUpInside	
  +=	
  (sender,	
  e)	
  =>	
  {
	
   	
   imageView.RemoveFromSuperview	
  ();
	
   };
}
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
Something Is Missing
public	
  override	
  void	
  ViewDidLoad	
  ()
{
	
   var	
  imageView	
  =	
  new	
  UIImageView	
  (IMG_VIEW_POSITION);
	
   var	
  image	
  =	
  UIImage.FromBundle	
  ("grumpy-­‐cat.jpg");
	
   imageView.Image	
  =	
  image;
	
   View.Add	
  (imageView);
	
  
	
   var	
  button	
  =	
  UIButton.FromType	
  (UIButtonType.RoundedRect);
	
   button.Frame	
  =	
  BUTTON_POSITION;
	
   View.Add	
  (button);
	
  
	
   button.TouchUpInside	
  +=	
  (sender,	
  e)	
  =>	
  {
	
   	
   imageView.RemoveFromSuperview	
  ();
	
   };
}
The garbage collector cannot see what’s
behind an innocent object
The Illusion
32	
  bytes
2	
  Mb
C#	
  UIImage
ObjC	
  UIImage
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
Dispose Your Resources
public	
  override	
  void	
  ViewDidLoad	
  ()
{
	
   var	
  imageView	
  =	
  new	
  UIImageView	
  (IMG_VIEW_POSITION);
	
   var	
  image	
  =	
  UIImage.FromBundle	
  ("grumpy-­‐cat.jpg");
	
   imageView.Image	
  =	
  image;
	
   View.Add	
  (imageView);
	
  
	
   var	
  button	
  =	
  UIButton.FromType	
  (UIButtonType.RoundedRect);
	
   button.Frame	
  =	
  BUTTON_POSITION;
	
   View.Add	
  (button);
	
  
	
   button.TouchUpInside	
  +=	
  (sender,	
  e)	
  =>	
  {
	
   	
   imageView.RemoveFromSuperview	
  ();
	
   	
   imageView.Dispose	
  ();
	
   	
   image.Dispose	
  ();
	
   };
}
Using Dispose
• Call Dispose() to release ownership of a resource
• Use with large native resources, such as
Images
Sounds
• Or scarce resources, such as
Files
Sockets
• Remember, lifecycle must be manually defined
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
iOS Puzzle 2
public	
  class	
  CustomView	
  :	
  UIView	
  {
	
   UIViewController	
  parent;
	
  
	
   public	
  CustomView	
  (UIViewController	
  parent)
	
   {
	
   	
   this.parent	
  =	
  parent;
	
   }
}
public	
  class	
  Puzzle2Controller	
  :	
  UIViewController
{
	
   public	
  override	
  void	
  ViewDidLoad	
  ()
	
   {
	
   	
   View.Add	
  (new	
  CustomView	
  (this));
	
   }
}
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
Indirect Cycles
public	
  class	
  CustomView	
  :	
  UIView	
  {
	
   UIViewController	
  parent;
	
  
	
   public	
  CustomView	
  (UIViewController	
  parent)
	
   {
	
   	
   this.parent	
  =	
  parent;
	
   }
}
public	
  class	
  Puzzle2Controller	
  :	
  UIViewController
{
	
   public	
  override	
  void	
  ViewDidLoad	
  ()
	
   {
	
   	
   View.Add	
  (new	
  CustomView	
  (this));
	
   }
}
Cycles in Objective-C
1
1
How those cycles happen
Indirect Cycles
C#
Puzzle2Controller
CustomView
View.Add	
  (...)
this.parent	
  =	
  ...
Objec;ve-­‐C
1
2
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
Using Weak References
public	
  class	
  CustomView	
  :	
  UIButton	
  {
	
   WeakReference<UIViewController>	
  parent;
	
  
	
   public	
  CustomView	
  (UIViewController	
  parent)
	
   {
	
   	
   this.parent	
  =	
  new	
  WeakReference<UIViewController>	
  (parent);
	
   }
}
public	
  class	
  Puzzle2Controller	
  :	
  UIViewController
{
	
   public	
  override	
  void	
  ViewDidLoad	
  ()
	
   {
	
   	
   View.Add	
  (new	
  CustomView	
  (this));
	
   }
}
Indirect cycles
• Inherited from Objective-C
• How to detect
When multiple objects point to each other
• Breaking those cycles
Use WeakReference
By disposing the parent
By explicitly nulling links
• What can trigger it under the hood
Non-wrapper subclasses of NSObject
With reference count > 2
01
02
03
04
05
06
07
08
09
10
11
12
13
14
iOS Puzzle 2 (Bonus)
public	
  class	
  CustomButton	
  :	
  UIButton	
  {
	
   public	
  CustomButton	
  ()	
  {}
}
public	
  class	
  Puzzle2Controller	
  :	
  UIViewController
{
	
   public	
  override	
  void	
  ViewDidLoad	
  ()
	
   {
	
   	
   var	
  button	
  =	
  new	
  CustomButton	
  ();
	
   	
   View.Add	
  (button);
	
   	
   button.TouchUpInside	
  +=	
  (sender,	
  e)	
  =>	
  
	
   	
   	
   this.RemoveFromParentViewController	
  ();
	
   }
}
01
02
03
04
05
06
07
08
09
10
11
12
13
14
Watch Your Lambdas
public	
  class	
  CustomButton	
  :	
  UIButton	
  {
	
   public	
  CustomButton	
  ()	
  {}
}
public	
  class	
  Puzzle2Controller	
  :	
  UIViewController
{
	
   public	
  override	
  void	
  ViewDidLoad	
  ()
	
   {
	
   	
   var	
  button	
  =	
  new	
  CustomButton	
  ();
	
   	
   View.Add	
  (button);
	
   	
   button.TouchUpInside	
  +=	
  (sender,	
  e)	
  =>	
  
	
   	
   	
   this.RemoveFromParentViewController	
  ();
	
   }
}
Measure before assuming something is wrong
Enabling GC logging on Android
A Small Detour
$adb shell setprop debug.mono.env "MONO_LOG_LEVEL=debug|MONO_LOG_MASK=gc"
D/Mono ( 5862): GC_MAJOR: (user request) pause 2.82ms, total 3.06ms,
bridge 20.96 major 608K/808K los 9K/20K
01
02
03
04
05
06
07
08
09
10
11
Android Puzzle
public	
  class	
  Tweet	
  {}
public	
  class	
  Puzzle1	
  :	
  ListActivity
{
	
   protected	
  override	
  void	
  OnCreate	
  (Bundle	
  bundle)
	
   {
	
   	
   base.OnCreate	
  (bundle);
	
   	
   var	
  data	
  =	
  new	
  Tweet[]	
  {	
  tweet0,	
  tweet1,	
  tweet2,	
  tweet3	
  };
	
   	
   ListAdapter	
  =	
  new	
  ArrayAdapter	
  (this,	
  Resource.Layout.TextViewItem,	
  data);
	
   }
}
01
02
03
04
05
06
07
08
09
10
11
Over-Sharing
public	
  class	
  Tweet	
  {}
public	
  class	
  Puzzle1	
  :	
  ListActivity
{
	
   protected	
  override	
  void	
  OnCreate	
  (Bundle	
  bundle)
	
   {
	
   	
   base.OnCreate	
  (bundle);
	
   	
   var	
  data	
  =	
  new	
  Tweet[]	
  {	
  tweet0,	
  tweet1,	
  tweet2,	
  tweet3	
  };
	
   	
   ListAdapter	
  =	
  new	
  ArrayAdapter	
  (this,	
  Resource.Layout.TextViewItem,	
  data);
	
   }
}
A tale of two heaps
Cross-Heap References
ArrayAdapter
ArrayList
Tweets
C#	
  Object
Java	
  Object
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
Do It All from C# Land
public	
  class	
  Tweet	
  {}
public	
  class	
  TweetAdapter	
  :	
  BaseAdapter<Tweet>	
  {
	
   List<Tweet>	
  tweets;
	
   public	
  override	
  Tweet	
  this[int	
  position]	
  {
	
   	
   get	
  {	
  return	
  tweets	
  [position];	
  }
	
   }
	
   public	
  override	
  int	
  Count	
  {
	
   	
   get	
  {	
  return	
  tweets.Count;	
  }
	
   }
}
public	
  class	
  Puzzle3	
  :	
  ListActivity
{
	
   protected	
  override	
  void	
  OnCreate	
  (Bundle	
  bundle)	
  {
	
   	
   var	
  data	
  =	
  new	
  List<Tweet>	
  ()	
  {	
  tweet0,	
  tweet1,	
  tweet2,	
  tweet3	
  };
	
   	
   ListAdapter	
  =	
  new	
  TweetAdapter	
  (this,	
  data);
	
   }
}
The a!er effect
Cross-Heap References
TweetsAdapter
List<Tweet>
Tweets
C#	
  Object
Java	
  Object
Avoid Cross-Heap References
• It’s expensive for Java to see a C# object
And vice-versa
• Performance cost of language crossing
• Higher Garbage Collector costs
• Your objects are effectively being mirrored
So using twice as much memory
Performance Tips
• The less you allocate, the less o!en the GC runs
• The less live data you have, the quicker the GC runs
• Small, short-lived objects are cheap
• Don’t allocate large (> 8Kb) objects that die young
• Avoid writing to reference fields
• Better: avoid having reference fields
• Don’t use free lists
Q&A
Use SGen unless you have
good reason not to
SGen vs Boehm
Memory Management on iOS
• Reference Counting
• Each object has a reference count field
• Incremented when something points to it
• Decremented when something stops pointing to it
• Object is released when count equals to zero
Xamarin.iOS Approach
• Two classes of objects
• Wrappers
Comes from native frame
UIButton, NSString, etc
• User types
User code that extend the above
MyButton
Wrappers
• Retain on construction
• Release on finalization/dispose
• We don’t care if the managed object goes away
User Types
• Retain/Release like wrappers
• Can have custom state
• We make a gc handle (think of a static field) point to the object if
reference count > 1
• Managed object is kept around if native is interested in it
01
02
03
04
05
06
07
08
09
10
11
User Types
class	
  MyButton	
  :	
  UIButton	
  {}
...
public	
  override	
  void	
  ViewDidLoad	
  ()
{
	
   var	
  button	
  =	
  new	
  MyButton	
  ();	
  //ref	
  count	
  ==	
  1,	
  no	
  gc	
  handle
	
   this.View.Add	
  (button);	
  //ref	
  count	
  ==	
  2,	
  gc	
  handle	
  created
	
   ...
	
   button.RemoveFromSuperView	
  ();	
  //	
  ref	
  count	
  ==	
  1,	
  gc	
  handle	
  removed
}
First Rule of Finalizers:
Don’t Use Finalizers!
• They’re not guaranteed to run within any deadline
• They don’t run in a specific sequence
• They make objects live longer
• The GC doesn’t know about unmanaged resources
Finalizers
• Run in a dedicated finalizer thread
• Run concurrently with other threads
• Keep their objects and those referenced from there alive for
another GC round
Root
has
Finalizer
an object with a finalizer must be kept alive
Finalizer Illustration
Root
has
Finalizer
so must all objects reachable from it
Finalizer Illustration
Root
has
Finalizer
so must all objects reachable from it
Finalizer Illustration
Root
has
Finalizer
they die in the next collection
Finalizer Illustration
Root
they die in the next collection
Finalizer Illustration
Root
has
Finalizer
unless ...
Finalizer Illustration
Root
has
Finalizer
the finalizer resurrects them
Finalizer Illustration
Root
the finalizer resurrects them
Finalizer Illustration
Root
the finalizer resurrects them
Finalizer Illustration
Stuff You Can Do with Finalizers
(and Probably Shouldn’t)
• Resurrect their objects
• Re-register for finalization
• Non-critical vs critical finalizers
Nursery
Root 1 Root 2
Major Heap
keeping track of major→nursery references
The Write Barrier
Nursery
Root 1 Root 2
Major Heap
keeping track of major→nursery references
The Write Barrier
What Are Roots?
• static variables
• Stack frames in managed threads
• Finalizer queue
• References registered in unmanaged code
01
02
03
04
05
06
07
Android Puzzle 2
public	
  class	
  CommitLogAdapter	
  :	
  BaseAdapter	
  {
	
   Dictionary<string,	
  CommitObject>	
  commitCache;
	
   	
  
	
   CommitObject	
  GetCommit	
  (string	
  hash)	
  {
	
   	
   return	
  commitCache	
  [hash];
	
   }
}
01
02
03
04
05
06
07
Too Many Objects
public	
  class	
  CommitLogItemAdapter	
  :	
  BaseAdapter	
  {
	
   Dictionary<string,	
  CommitObject>	
  commitCache;
	
   	
  
	
   CommitObject	
  GetCommit	
  (string	
  hash)	
  {
	
   	
   return	
  commitCache	
  [hash];
	
   }
}
It must inspect special objects and
everything they reference
Android GC Interop
CommitLogAdapter
commitsCache
01
02
03
04
05
06
07
Use Static Caches
public	
  class	
  CommitLogItemAdapter	
  :	
  BaseAdapter	
  {
	
   static	
  Dictionary<string,	
  CommitObject>	
  commitCache;
	
   	
  
	
   static	
  CommitObject	
  GetCommit	
  (string	
  hash)	
  {
	
   	
   return	
  commitCache	
  [hash];
	
   }
}
Taking care of special objects
• If it extends the Android framework, it’s a special object
• The Garbage Collector scans them in a different way
That is slower
It rescans all objects they reference
Avoid pointing to large group of objects
• Explicitly manage the lifecycle of long living objects
Static caches and collections
Helps measuring consumption

Weitere ähnliche Inhalte

Was ist angesagt?

Memory management in iOS.
Memory management in iOS.Memory management in iOS.
Memory management in iOS.HSIEH CHING-FAN
 
Memory Management on iOS
Memory Management on iOSMemory Management on iOS
Memory Management on iOSMake School
 
Distributing information on iOS
Distributing information on iOSDistributing information on iOS
Distributing information on iOSMake School
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCAWhymca
 
Maintainable JavaScript 2011
Maintainable JavaScript 2011Maintainable JavaScript 2011
Maintainable JavaScript 2011Nicholas Zakas
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesSiarhei Barysiuk
 
Connect.Tech- Swift Memory Management
Connect.Tech- Swift Memory ManagementConnect.Tech- Swift Memory Management
Connect.Tech- Swift Memory Managementstable|kernel
 
Design patterns - Common Solutions to Common Problems - Brad Wood
Design patterns -  Common Solutions to Common Problems - Brad WoodDesign patterns -  Common Solutions to Common Problems - Brad Wood
Design patterns - Common Solutions to Common Problems - Brad WoodOrtus Solutions, Corp
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろうUnity Technologies Japan K.K.
 
Build Widgets
Build WidgetsBuild Widgets
Build Widgetsscottw
 
Realm.io par Clement Sauvage
Realm.io par Clement SauvageRealm.io par Clement Sauvage
Realm.io par Clement SauvageCocoaHeads France
 
Mobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve MobileMobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve MobileKonstantin Loginov
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of JavascriptTarek Yehia
 
Introduction to MVC in iPhone Development
Introduction to MVC in iPhone DevelopmentIntroduction to MVC in iPhone Development
Introduction to MVC in iPhone DevelopmentVu Tran Lam
 
Advanced JavaScript Concepts
Advanced JavaScript ConceptsAdvanced JavaScript Concepts
Advanced JavaScript ConceptsNaresh Kumar
 
Advanced javascript
Advanced javascriptAdvanced javascript
Advanced javascriptDoeun KOCH
 

Was ist angesagt? (20)

Memory management in iOS.
Memory management in iOS.Memory management in iOS.
Memory management in iOS.
 
Memory Management on iOS
Memory Management on iOSMemory Management on iOS
Memory Management on iOS
 
Distributing information on iOS
Distributing information on iOSDistributing information on iOS
Distributing information on iOS
 
Lecture 3-ARC
Lecture 3-ARCLecture 3-ARC
Lecture 3-ARC
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCA
 
iOS5 NewStuff
iOS5 NewStuffiOS5 NewStuff
iOS5 NewStuff
 
Maintainable JavaScript 2011
Maintainable JavaScript 2011Maintainable JavaScript 2011
Maintainable JavaScript 2011
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best Practices
 
Connect.Tech- Swift Memory Management
Connect.Tech- Swift Memory ManagementConnect.Tech- Swift Memory Management
Connect.Tech- Swift Memory Management
 
Design patterns - Common Solutions to Common Problems - Brad Wood
Design patterns -  Common Solutions to Common Problems - Brad WoodDesign patterns -  Common Solutions to Common Problems - Brad Wood
Design patterns - Common Solutions to Common Problems - Brad Wood
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
 
Build Widgets
Build WidgetsBuild Widgets
Build Widgets
 
Realm.io par Clement Sauvage
Realm.io par Clement SauvageRealm.io par Clement Sauvage
Realm.io par Clement Sauvage
 
Mobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve MobileMobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve Mobile
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of Javascript
 
Air Drag And Drop
Air Drag And DropAir Drag And Drop
Air Drag And Drop
 
Introduction to MVC in iPhone Development
Introduction to MVC in iPhone DevelopmentIntroduction to MVC in iPhone Development
Introduction to MVC in iPhone Development
 
Advanced JavaScript Concepts
Advanced JavaScript ConceptsAdvanced JavaScript Concepts
Advanced JavaScript Concepts
 
ERGroupware
ERGroupwareERGroupware
ERGroupware
 
Advanced javascript
Advanced javascriptAdvanced javascript
Advanced javascript
 

Andere mochten auch

Memory management in Android
Memory management in AndroidMemory management in Android
Memory management in AndroidKeyhan Asghari
 
Android memory fundamentals
Android memory fundamentalsAndroid memory fundamentals
Android memory fundamentalsTaras Leskiv
 
Memory Leak Analysis in Android Games
Memory Leak Analysis in Android GamesMemory Leak Analysis in Android Games
Memory Leak Analysis in Android GamesHeghine Hakobyan
 
Vietnam Mobile Day 2013: Memory Management For Android Apps
Vietnam Mobile Day 2013: Memory Management For Android AppsVietnam Mobile Day 2013: Memory Management For Android Apps
Vietnam Mobile Day 2013: Memory Management For Android AppsGameLandVN
 
Android Project Training in Ahmedabad
Android Project Training in AhmedabadAndroid Project Training in Ahmedabad
Android Project Training in AhmedabadDevelopers Academy
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in AndroidOpersys inc.
 
Memory management in Andoid
Memory management in AndoidMemory management in Andoid
Memory management in AndoidMonkop Inc
 
Android - Preventing common memory leaks
Android - Preventing common memory leaksAndroid - Preventing common memory leaks
Android - Preventing common memory leaksAli Muzaffar
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in AndroidOpersys inc.
 
Apple iOS Introduction
Apple iOS IntroductionApple iOS Introduction
Apple iOS IntroductionPratik Vyas
 
Symbian mobile operating system ppt
Symbian mobile operating system pptSymbian mobile operating system ppt
Symbian mobile operating system pptDevesh Singh
 

Andere mochten auch (16)

Memory management in Android
Memory management in AndroidMemory management in Android
Memory management in Android
 
Android memory fundamentals
Android memory fundamentalsAndroid memory fundamentals
Android memory fundamentals
 
Memory Leak Analysis in Android Games
Memory Leak Analysis in Android GamesMemory Leak Analysis in Android Games
Memory Leak Analysis in Android Games
 
Vietnam Mobile Day 2013: Memory Management For Android Apps
Vietnam Mobile Day 2013: Memory Management For Android AppsVietnam Mobile Day 2013: Memory Management For Android Apps
Vietnam Mobile Day 2013: Memory Management For Android Apps
 
Android Project Training in Ahmedabad
Android Project Training in AhmedabadAndroid Project Training in Ahmedabad
Android Project Training in Ahmedabad
 
Monkey space 2013
Monkey space 2013Monkey space 2013
Monkey space 2013
 
Memory in Android
Memory in AndroidMemory in Android
Memory in Android
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
Android & IOS
Android & IOSAndroid & IOS
Android & IOS
 
Memory management in Andoid
Memory management in AndoidMemory management in Andoid
Memory management in Andoid
 
Gc in android
Gc in androidGc in android
Gc in android
 
Android - Preventing common memory leaks
Android - Preventing common memory leaksAndroid - Preventing common memory leaks
Android - Preventing common memory leaks
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
Apple iOS Introduction
Apple iOS IntroductionApple iOS Introduction
Apple iOS Introduction
 
Memory management
Memory managementMemory management
Memory management
 
Symbian mobile operating system ppt
Symbian mobile operating system pptSymbian mobile operating system ppt
Symbian mobile operating system ppt
 

Ähnlich wie Advanced Memory Management on iOS and Android - Mark Probst and Rodrigo Kumpera

Gitter marionette deck
Gitter marionette deckGitter marionette deck
Gitter marionette deckMike Bartlett
 
Android UI Development: Tips, Tricks, and Techniques
Android UI Development: Tips, Tricks, and TechniquesAndroid UI Development: Tips, Tricks, and Techniques
Android UI Development: Tips, Tricks, and TechniquesEdgar Gonzalez
 
Android UI Tips, Tricks and Techniques
Android UI Tips, Tricks and TechniquesAndroid UI Tips, Tricks and Techniques
Android UI Tips, Tricks and TechniquesMarakana Inc.
 
angularjsmeetup-150303044616-conversion-gate01
angularjsmeetup-150303044616-conversion-gate01angularjsmeetup-150303044616-conversion-gate01
angularjsmeetup-150303044616-conversion-gate01Teo E
 
Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...go_oh
 
Performance #1: Memory
Performance #1: MemoryPerformance #1: Memory
Performance #1: MemoryYonatan Levin
 
Building React Applications with Redux
Building React Applications with ReduxBuilding React Applications with Redux
Building React Applications with ReduxFITC
 
Developing maintainable Cordova applications
Developing maintainable Cordova applicationsDeveloping maintainable Cordova applications
Developing maintainable Cordova applicationsIvano Malavolta
 
杜增强-Flex3组件生命周期
杜增强-Flex3组件生命周期杜增强-Flex3组件生命周期
杜增强-Flex3组件生命周期增强 杜
 
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationLotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationSean Burgess
 
Garbage collection
Garbage collectionGarbage collection
Garbage collectionSomya Bagai
 
Angular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupAngular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupDavid Barreto
 
Advanced iOS Build Mechanics, Sebastien Pouliot
Advanced iOS Build Mechanics, Sebastien PouliotAdvanced iOS Build Mechanics, Sebastien Pouliot
Advanced iOS Build Mechanics, Sebastien PouliotXamarin
 
Understanding memory management in xamarin forms
Understanding memory management in xamarin formsUnderstanding memory management in xamarin forms
Understanding memory management in xamarin formsTsvyatko Konov
 
Slaying Sacred Cows: Deconstructing Dependency Injection
Slaying Sacred Cows: Deconstructing Dependency InjectionSlaying Sacred Cows: Deconstructing Dependency Injection
Slaying Sacred Cows: Deconstructing Dependency InjectionTomer Gabel
 
From Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceFrom Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceSebastian Springer
 
Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Sam Muhanguzi
 

Ähnlich wie Advanced Memory Management on iOS and Android - Mark Probst and Rodrigo Kumpera (20)

Gitter marionette deck
Gitter marionette deckGitter marionette deck
Gitter marionette deck
 
Android UI Development: Tips, Tricks, and Techniques
Android UI Development: Tips, Tricks, and TechniquesAndroid UI Development: Tips, Tricks, and Techniques
Android UI Development: Tips, Tricks, and Techniques
 
Android UI Tips, Tricks and Techniques
Android UI Tips, Tricks and TechniquesAndroid UI Tips, Tricks and Techniques
Android UI Tips, Tricks and Techniques
 
angularjsmeetup-150303044616-conversion-gate01
angularjsmeetup-150303044616-conversion-gate01angularjsmeetup-150303044616-conversion-gate01
angularjsmeetup-150303044616-conversion-gate01
 
Angular js meetup
Angular js meetupAngular js meetup
Angular js meetup
 
Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...
 
Performance #1 memory
Performance #1   memoryPerformance #1   memory
Performance #1 memory
 
Performance #1: Memory
Performance #1: MemoryPerformance #1: Memory
Performance #1: Memory
 
Building React Applications with Redux
Building React Applications with ReduxBuilding React Applications with Redux
Building React Applications with Redux
 
Developing maintainable Cordova applications
Developing maintainable Cordova applicationsDeveloping maintainable Cordova applications
Developing maintainable Cordova applications
 
Android Apps the Right Way
Android Apps the Right WayAndroid Apps the Right Way
Android Apps the Right Way
 
杜增强-Flex3组件生命周期
杜增强-Flex3组件生命周期杜增强-Flex3组件生命周期
杜增强-Flex3组件生命周期
 
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationLotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
 
Garbage collection
Garbage collectionGarbage collection
Garbage collection
 
Angular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupAngular Optimization Web Performance Meetup
Angular Optimization Web Performance Meetup
 
Advanced iOS Build Mechanics, Sebastien Pouliot
Advanced iOS Build Mechanics, Sebastien PouliotAdvanced iOS Build Mechanics, Sebastien Pouliot
Advanced iOS Build Mechanics, Sebastien Pouliot
 
Understanding memory management in xamarin forms
Understanding memory management in xamarin formsUnderstanding memory management in xamarin forms
Understanding memory management in xamarin forms
 
Slaying Sacred Cows: Deconstructing Dependency Injection
Slaying Sacred Cows: Deconstructing Dependency InjectionSlaying Sacred Cows: Deconstructing Dependency Injection
Slaying Sacred Cows: Deconstructing Dependency Injection
 
From Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceFrom Zero to Hero – Web Performance
From Zero to Hero – Web Performance
 
Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Gwt and rpc use 2007 1
Gwt and rpc use 2007 1
 

Mehr von Xamarin

Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...Xamarin
 
Xamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App CenterXamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App CenterXamarin
 
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinGet the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinXamarin
 
Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for XamarinGet the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for XamarinXamarin
 
Creative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePushCreative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePushXamarin
 
Build Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft AzureBuild Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft AzureXamarin
 
Exploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin WorkbooksExploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin WorkbooksXamarin
 
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for XamarinDesktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for XamarinXamarin
 
Developer’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine LearningDeveloper’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine LearningXamarin
 
Customizing Xamarin.Forms UI
Customizing Xamarin.Forms UICustomizing Xamarin.Forms UI
Customizing Xamarin.Forms UIXamarin
 
Session 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and ResourcesSession 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and ResourcesXamarin
 
Session 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and ProfitabilitySession 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and ProfitabilityXamarin
 
Session 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile PracticeSession 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile PracticeXamarin
 
Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud Xamarin
 
SkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.FormsSkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.FormsXamarin
 
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and AzureBuilding Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and AzureXamarin
 
Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017Xamarin
 
Connected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft AzureConnected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft AzureXamarin
 
Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Xamarin
 
Building Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual StudioBuilding Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual StudioXamarin
 

Mehr von Xamarin (20)

Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...
 
Xamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App CenterXamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App Center
 
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinGet the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
 
Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for XamarinGet the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
 
Creative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePushCreative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePush
 
Build Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft AzureBuild Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft Azure
 
Exploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin WorkbooksExploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin Workbooks
 
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for XamarinDesktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
 
Developer’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine LearningDeveloper’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine Learning
 
Customizing Xamarin.Forms UI
Customizing Xamarin.Forms UICustomizing Xamarin.Forms UI
Customizing Xamarin.Forms UI
 
Session 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and ResourcesSession 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and Resources
 
Session 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and ProfitabilitySession 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and Profitability
 
Session 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile PracticeSession 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile Practice
 
Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud
 
SkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.FormsSkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.Forms
 
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and AzureBuilding Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
 
Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017
 
Connected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft AzureConnected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft Azure
 
Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017
 
Building Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual StudioBuilding Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual Studio
 

Kürzlich hochgeladen

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 

Kürzlich hochgeladen (20)

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 

Advanced Memory Management on iOS and Android - Mark Probst and Rodrigo Kumpera

  • 3. What a Garbage Collector Does • Gives you memory for your objects • Computes which objects are reachable • Gets rid of the rest (= garbage) h"p://www.flickr.com/photos/tweng/2235972313/
  • 4. object reference object with reference one object ... … referencing ... … another Basic Garbage Collection
  • 13. Two Generations • Generational hypothesis Most objects die young • Nursery Where (small) objects are born • Major Where they are copied to when they mature • Large Object Space Part of the major generation, objects > 8Kb Typically large arrays
  • 14. Stop-the-World • Nursery collection pauses are short • Major collection pauses can take a long time • All threads registered with the runtime are stopped That includes the main run loop thread • iOS animations continue to run in a separate process
  • 15. Common Issues • Let’s examine three common issues • Given a trivial piece code Find the issue Understand the problem Learn how to fix it
  • 16. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 iOS Puzzle 1 public  override  void  ViewDidLoad  () {   var  imageView  =  new  UIImageView  (IMG_VIEW_POSITION);   var  image  =  UIImage.FromBundle  ("grumpy-­‐cat.jpg");   imageView.Image  =  image;   View.Add  (imageView);     var  button  =  UIButton.FromType  (UIButtonType.RoundedRect);   button.Frame  =  BUTTON_POSITION;   View.Add  (button);     button.TouchUpInside  +=  (sender,  e)  =>  {     imageView.RemoveFromSuperview  ();   }; }
  • 17. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 Something Is Missing public  override  void  ViewDidLoad  () {   var  imageView  =  new  UIImageView  (IMG_VIEW_POSITION);   var  image  =  UIImage.FromBundle  ("grumpy-­‐cat.jpg");   imageView.Image  =  image;   View.Add  (imageView);     var  button  =  UIButton.FromType  (UIButtonType.RoundedRect);   button.Frame  =  BUTTON_POSITION;   View.Add  (button);     button.TouchUpInside  +=  (sender,  e)  =>  {     imageView.RemoveFromSuperview  ();   }; }
  • 18. The garbage collector cannot see what’s behind an innocent object The Illusion 32  bytes 2  Mb C#  UIImage ObjC  UIImage
  • 19. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 Dispose Your Resources public  override  void  ViewDidLoad  () {   var  imageView  =  new  UIImageView  (IMG_VIEW_POSITION);   var  image  =  UIImage.FromBundle  ("grumpy-­‐cat.jpg");   imageView.Image  =  image;   View.Add  (imageView);     var  button  =  UIButton.FromType  (UIButtonType.RoundedRect);   button.Frame  =  BUTTON_POSITION;   View.Add  (button);     button.TouchUpInside  +=  (sender,  e)  =>  {     imageView.RemoveFromSuperview  ();     imageView.Dispose  ();     image.Dispose  ();   }; }
  • 20. Using Dispose • Call Dispose() to release ownership of a resource • Use with large native resources, such as Images Sounds • Or scarce resources, such as Files Sockets • Remember, lifecycle must be manually defined
  • 21. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 iOS Puzzle 2 public  class  CustomView  :  UIView  {   UIViewController  parent;     public  CustomView  (UIViewController  parent)   {     this.parent  =  parent;   } } public  class  Puzzle2Controller  :  UIViewController {   public  override  void  ViewDidLoad  ()   {     View.Add  (new  CustomView  (this));   } }
  • 22. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 Indirect Cycles public  class  CustomView  :  UIView  {   UIViewController  parent;     public  CustomView  (UIViewController  parent)   {     this.parent  =  parent;   } } public  class  Puzzle2Controller  :  UIViewController {   public  override  void  ViewDidLoad  ()   {     View.Add  (new  CustomView  (this));   } }
  • 24. How those cycles happen Indirect Cycles C# Puzzle2Controller CustomView View.Add  (...) this.parent  =  ... Objec;ve-­‐C 1 2
  • 25. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 Using Weak References public  class  CustomView  :  UIButton  {   WeakReference<UIViewController>  parent;     public  CustomView  (UIViewController  parent)   {     this.parent  =  new  WeakReference<UIViewController>  (parent);   } } public  class  Puzzle2Controller  :  UIViewController {   public  override  void  ViewDidLoad  ()   {     View.Add  (new  CustomView  (this));   } }
  • 26. Indirect cycles • Inherited from Objective-C • How to detect When multiple objects point to each other • Breaking those cycles Use WeakReference By disposing the parent By explicitly nulling links • What can trigger it under the hood Non-wrapper subclasses of NSObject With reference count > 2
  • 27. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 iOS Puzzle 2 (Bonus) public  class  CustomButton  :  UIButton  {   public  CustomButton  ()  {} } public  class  Puzzle2Controller  :  UIViewController {   public  override  void  ViewDidLoad  ()   {     var  button  =  new  CustomButton  ();     View.Add  (button);     button.TouchUpInside  +=  (sender,  e)  =>         this.RemoveFromParentViewController  ();   } }
  • 28. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 Watch Your Lambdas public  class  CustomButton  :  UIButton  {   public  CustomButton  ()  {} } public  class  Puzzle2Controller  :  UIViewController {   public  override  void  ViewDidLoad  ()   {     var  button  =  new  CustomButton  ();     View.Add  (button);     button.TouchUpInside  +=  (sender,  e)  =>         this.RemoveFromParentViewController  ();   } }
  • 29. Measure before assuming something is wrong Enabling GC logging on Android A Small Detour $adb shell setprop debug.mono.env "MONO_LOG_LEVEL=debug|MONO_LOG_MASK=gc" D/Mono ( 5862): GC_MAJOR: (user request) pause 2.82ms, total 3.06ms, bridge 20.96 major 608K/808K los 9K/20K
  • 30. 01 02 03 04 05 06 07 08 09 10 11 Android Puzzle public  class  Tweet  {} public  class  Puzzle1  :  ListActivity {   protected  override  void  OnCreate  (Bundle  bundle)   {     base.OnCreate  (bundle);     var  data  =  new  Tweet[]  {  tweet0,  tweet1,  tweet2,  tweet3  };     ListAdapter  =  new  ArrayAdapter  (this,  Resource.Layout.TextViewItem,  data);   } }
  • 31. 01 02 03 04 05 06 07 08 09 10 11 Over-Sharing public  class  Tweet  {} public  class  Puzzle1  :  ListActivity {   protected  override  void  OnCreate  (Bundle  bundle)   {     base.OnCreate  (bundle);     var  data  =  new  Tweet[]  {  tweet0,  tweet1,  tweet2,  tweet3  };     ListAdapter  =  new  ArrayAdapter  (this,  Resource.Layout.TextViewItem,  data);   } }
  • 32. A tale of two heaps Cross-Heap References ArrayAdapter ArrayList Tweets C#  Object Java  Object
  • 33. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 Do It All from C# Land public  class  Tweet  {} public  class  TweetAdapter  :  BaseAdapter<Tweet>  {   List<Tweet>  tweets;   public  override  Tweet  this[int  position]  {     get  {  return  tweets  [position];  }   }   public  override  int  Count  {     get  {  return  tweets.Count;  }   } } public  class  Puzzle3  :  ListActivity {   protected  override  void  OnCreate  (Bundle  bundle)  {     var  data  =  new  List<Tweet>  ()  {  tweet0,  tweet1,  tweet2,  tweet3  };     ListAdapter  =  new  TweetAdapter  (this,  data);   } }
  • 34. The a!er effect Cross-Heap References TweetsAdapter List<Tweet> Tweets C#  Object Java  Object
  • 35. Avoid Cross-Heap References • It’s expensive for Java to see a C# object And vice-versa • Performance cost of language crossing • Higher Garbage Collector costs • Your objects are effectively being mirrored So using twice as much memory
  • 36. Performance Tips • The less you allocate, the less o!en the GC runs • The less live data you have, the quicker the GC runs • Small, short-lived objects are cheap • Don’t allocate large (> 8Kb) objects that die young • Avoid writing to reference fields • Better: avoid having reference fields • Don’t use free lists
  • 37. Q&A
  • 38. Use SGen unless you have good reason not to SGen vs Boehm
  • 39. Memory Management on iOS • Reference Counting • Each object has a reference count field • Incremented when something points to it • Decremented when something stops pointing to it • Object is released when count equals to zero
  • 40. Xamarin.iOS Approach • Two classes of objects • Wrappers Comes from native frame UIButton, NSString, etc • User types User code that extend the above MyButton
  • 41. Wrappers • Retain on construction • Release on finalization/dispose • We don’t care if the managed object goes away
  • 42. User Types • Retain/Release like wrappers • Can have custom state • We make a gc handle (think of a static field) point to the object if reference count > 1 • Managed object is kept around if native is interested in it
  • 43. 01 02 03 04 05 06 07 08 09 10 11 User Types class  MyButton  :  UIButton  {} ... public  override  void  ViewDidLoad  () {   var  button  =  new  MyButton  ();  //ref  count  ==  1,  no  gc  handle   this.View.Add  (button);  //ref  count  ==  2,  gc  handle  created   ...   button.RemoveFromSuperView  ();  //  ref  count  ==  1,  gc  handle  removed }
  • 44. First Rule of Finalizers: Don’t Use Finalizers! • They’re not guaranteed to run within any deadline • They don’t run in a specific sequence • They make objects live longer • The GC doesn’t know about unmanaged resources
  • 45. Finalizers • Run in a dedicated finalizer thread • Run concurrently with other threads • Keep their objects and those referenced from there alive for another GC round
  • 46. Root has Finalizer an object with a finalizer must be kept alive Finalizer Illustration
  • 47. Root has Finalizer so must all objects reachable from it Finalizer Illustration
  • 48. Root has Finalizer so must all objects reachable from it Finalizer Illustration
  • 49. Root has Finalizer they die in the next collection Finalizer Illustration
  • 50. Root they die in the next collection Finalizer Illustration
  • 52. Root has Finalizer the finalizer resurrects them Finalizer Illustration
  • 53. Root the finalizer resurrects them Finalizer Illustration
  • 54. Root the finalizer resurrects them Finalizer Illustration
  • 55. Stuff You Can Do with Finalizers (and Probably Shouldn’t) • Resurrect their objects • Re-register for finalization • Non-critical vs critical finalizers
  • 56. Nursery Root 1 Root 2 Major Heap keeping track of major→nursery references The Write Barrier
  • 57. Nursery Root 1 Root 2 Major Heap keeping track of major→nursery references The Write Barrier
  • 58. What Are Roots? • static variables • Stack frames in managed threads • Finalizer queue • References registered in unmanaged code
  • 59. 01 02 03 04 05 06 07 Android Puzzle 2 public  class  CommitLogAdapter  :  BaseAdapter  {   Dictionary<string,  CommitObject>  commitCache;       CommitObject  GetCommit  (string  hash)  {     return  commitCache  [hash];   } }
  • 60. 01 02 03 04 05 06 07 Too Many Objects public  class  CommitLogItemAdapter  :  BaseAdapter  {   Dictionary<string,  CommitObject>  commitCache;       CommitObject  GetCommit  (string  hash)  {     return  commitCache  [hash];   } }
  • 61. It must inspect special objects and everything they reference Android GC Interop CommitLogAdapter commitsCache
  • 62. 01 02 03 04 05 06 07 Use Static Caches public  class  CommitLogItemAdapter  :  BaseAdapter  {   static  Dictionary<string,  CommitObject>  commitCache;       static  CommitObject  GetCommit  (string  hash)  {     return  commitCache  [hash];   } }
  • 63. Taking care of special objects • If it extends the Android framework, it’s a special object • The Garbage Collector scans them in a different way That is slower It rescans all objects they reference Avoid pointing to large group of objects • Explicitly manage the lifecycle of long living objects Static caches and collections Helps measuring consumption