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

相关文章
相关标签/搜索