gpt4 book ai didi

ios - NSFileManager 的 moveItemAtPath 是否为 :toPath:error method load the file being moved into memory?

转载 作者:行者123 更新时间:2023-11-28 20:56:08 25 4
gpt4 key购买 nike

在我最新的应用程序更新中,我将每个用户的 .sqlite 数据库移动到不同的目录。我正在使用 Core Data 方法 migratePersistentStore:toURL:options:withType:error,一些用户的应用程序由于使用过多的内存而关闭。所以我恢复到 NSFileManager 的 moveItemAtPath:toPath:error 方法。我不认为这会将数据库加载到内存中的方式与 migratePersistentStore:toURL:options:withType:error 相同,但我担心移动非常大的数据库仍会出现相同的内存问题。我可以使用一些建议 - 有没有人确定文件在移动时是否加载到内存中?有没有办法以尊重设备内存的方式移动非常大的文件?有没有比 moveItemAtPath:toPath:error 更好的方法?

最佳答案

我同意你的看法,移动 NSFileManager 应该只会改变文件系统中的链接,不会将任何内容加载到内存中。但是,如果您真的想确定,请不要相信您在 Stack Overflow 上获得的答案,请在您的应用程序中自行测试!在 Xcode 下运行您的应用程序时,依次单击Debug NavigatorShow Debug Gauges 工具和Memory。它看起来很漂亮。

enter image description here

然后测试您的一个文件移动并验证没有内存峰值。

关于ios - NSFileManager 的 moveItemAtPath 是否为 :toPath:error method load the file being moved into memory?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52231570/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com