我的应用程序在 iphone7 、 iphone 11 (真实设备)上运行得很好,但在 iphone6 和 iphone XR 中导航到另一个页面时就会崩溃。我从 bugsnag 得到的错误是
内存不足未知方法,该应用程序可能在前台时被操作系统终止
在查看 Xcode 中的内存泄漏配置文件后,我发现了 2 个进程:
1.VM:ImageIO_PNG_Data 占用了太多内存 ~ 400 MiB
2.VM:CoreAnimation 占用了太多内存。~ 700 MiB
对于图像,我只是决定降低图像质量并减少内存使用量,但是对于 CoreAnimation,有人知道如何降低 React-Native 中的值吗?任何建议都会有所帮助。我使用反应导航从一个页面导航到另一个页面。
请检查下图以供参考:
请询问是否需要更多信息。
做了什么:
在 Android 中实现并DCIM directory在 android中特定地下载它。在 ios 中DocumentDir用于下载 pdf 或 docx 文件。使用 "rn-fetch-blob": "^0.12.0";
错误:
在 IOS 中,它在控制台中显示消息:
文件保存到/var/mobile/Containers/Data/Application/E6FDC2DD-7FCA-44DC-85C4-A275078F8825/Documents/wow13.pdf
要下载的代码是这样的:
downloadFileOnSuccess = async () => {
let dirs =
Platform.OS == 'ios'
? RNFetchBlob.fs.dirs.DocumentDir
: RNFetchBlob.fs.dirs.DCIMDir;
console.log(dirs, 'document path');
RNFetchBlob.config({
// response data will be saved to this path if it has access right.
fileCache: true,
path: dirs + `/wow13.pdf`,
})
.fetch(
'GET',
'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf',
{
//some headers ..
},
)
.then(res => { …Run Code Online (Sandbox Code Playgroud)