iOS Memory Deep Dive

WWDC 2018

Posted by Den on July 02, 2018 · 5 mins read
iOS Memory Deep Dive

iOS Memory Deep Dive

WWDC 2018

iOS Memory Deep Dive

WWDC 2018

didReceiveMemoryWarning( )

  • Don’t necessarily assume that a memory warning is your cause.
    The warning will occur when user gets a call, message, etc.
Be careful when you delete a cache in the didReceiveMemoryWarning( )
Access the compressed dictionary → Decompress the dictionary (Memory Increased) → Delete the data
Result: Same allocations (Compressed Dictionary = Updated Dictionary)

Tools for Profiling Footprint

Memory resource exception

vmmap

  • Virtual memory regions allocated in a process

vmmap + AWK

leaks

  • Objects that are allocated, but no longer referenced

heap

  • Objects allocated on the heap
  • Useful for identifying large object in memory and what allocated it

Enabling malloc stack logging

malloc_history

  • Backtraces for malloc and anonymous VM region allocations

Which tool to pick?

Images

  • Stop using UIGraphicsBeginImageContextWithOptions
  • Using UIGraphicsImageRenderer (iOS 10)
    Automatically picks best graphics format !

Downsampling

  • ImageIO can read image sizes and metadata information without dirtying memory
  • ImageIO can read resize images at cost of resized image only