Xcode 16.1 Instruments分析iOS模拟器内存遇初始化错误求助
问题描述
使用Xcode 16.1配套的Instruments工具分析iOS模拟器内存时,两种启动方式(Xcode -> Product -> Profile、Xcode -> Debug Navigator -> Memory Graph -> Profile In Instruments)均出现异常,不同版本模拟器报错如下:
- iOS 18.1模拟器:
Failed to generate memory graph for pid 73918: failed to create a VMUTaskMemoryScanner, probably because the target's libmalloc hasn't been initialize - iOS 16.1模拟器:
Failed to execute loader thread for /Library/Developer/CoreSimulator/Volumes/iOS_20B72/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 16.1.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/DVTInstrumentsFoundation.framework/liboainject.dylib in target; target process 31804 likely exited - iOS 17.0.1模拟器:异常交替出现,首次录制提示泄漏数据捕获错误,下次运行可正常加载,循环往复
环境配置:macOS Sequoia 15.2、Xcode 16.1(16B40)、Instruments 16.0(16B40)
已尝试操作:更换模拟器、重启软件/电脑、删除DerivedData、重置模拟器、修改编译配置
可行解决方案
- 同步Xcode与Instruments版本:当前Instruments 16.0与Xcode 16.1版本不匹配,重新安装Xcode 16.1以获取同版本的Instruments工具,避免版本兼容问题。
- 统一模拟器架构配置:在Xcode项目的
Build Settings中,搜索Architectures,设置为Standard Architectures (arm64, x86_64);将Build Active Architecture Only在Debug/Profile模式下改为NO,确保模拟器能适配对应架构。 - 关闭GPU帧捕获功能:打开iOS模拟器的
Debug菜单,取消勾选Enable GPU Frame Capture,避免图形相关配置干扰Instruments的注入流程。 - 手动清理模拟器缓存:通过
xcrun simctl list devices命令获取目标模拟器UUID,前往~/Library/Developer/CoreSimulator/Devices/[模拟器UUID]/data/Library/Caches目录,删除所有缓存文件后重启模拟器。 - 直接从Instruments启动应用:打开Instruments后,选择
Memory Graph Debugger或Leaks模板,手动选择目标应用和对应模拟器启动,绕开Xcode传递的异常参数。 - 检查并调整SIP状态:在终端执行
csrutil status查看系统完整性保护状态,若已关闭则开启后重试;若开启仍有问题,可临时关闭SIP(需重启进入恢复模式操作,操作完成后务必重新开启)。 - 重新下载模拟器Runtime:打开Xcode的
Settings -> Platforms,找到异常的iOS版本,点击Remove删除后重新下载安装,修复可能损坏的Runtime文件。
内容的提问来源于stack exchange,提问作者Divine
相关产品推荐
相关产品推荐

