以前提过优化内存进行大对象处理这个点,今天看苹果文档正好有说起一个思路,这个思路大体是这个样子:html
尽可能避免使用大的资源文件若是能使用小的。git
让系统选择格式的图片资源根据设备的状况而不是直接使用高清分辨率的图片。github
避免把整个大的文件加入到内存中,而是使用mmap和munmap函数将文件的某些部分映射到内存中。app
MMKV--基于 mmap 的 iOS 高性能通用 key-value 组件函数
iOS图片加载速度极限优化—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