iOS內存優化技巧內存映射mmap

前言

以前提過優化內存進行大對象處理這個點,今天看蘋果文檔正好有說起一個思路,這個思路大體是這個樣子:html

  1. 儘可能避免使用大的資源文件若是能使用小的。git

  2. 讓系統選擇格式的圖片資源根據設備的狀況而不是直接使用高清分辨率的圖片。github

  3. 避免把整個大的文件加入到內存中,而是使用mmap和munmap函數將文件的某些部分映射到內存中。app

mmap詳解

Mapping Files Into Memoryide

iOS中的一些使用場景

MMKV--基於 mmap 的 iOS 高性能通用 key-value 組件函數

iOS圖片加載速度極限優化—FastImageCache解析性能

FastImageCache優化

注意

If you pass the DataReadingMappedIfSafe option to init(contentsOfFile:options:), files are memory mapped only when it’s possible to do so and the file is determined to be on a volume that can’t be removed or disappear suddenly.ui

參考連接:

Mapping Files Into Memory.net

iOS內存映射mmap詳解

Performance Tips

相關文章
相關標籤/搜索