gpt4 book ai didi

ios - iOS Realm 迁移内存泄漏

转载 作者:行者123 更新时间:2023-11-30 13:06:37 25 4
gpt4 key购买 nike

我在使用 Realm (v1.0.2) 迁移期间遇到内存泄漏。我的代码如下所示:

        let config = Realm.Configuration(
schemaVersion: 1,
migrationBlock: { migration, oldSchemaVersion in
// We haven’t migrated anything yet, so oldSchemaVersion == 0
if (oldSchemaVersion < 1) {
migration.enumerate(MyClassRealm.className(), { (oldObject, newObject) in

newObject!["remoteId"] = 0
newObject!["deleted"] = false
newObject!["dirty"] = true
newObject!["updated"] = 0
})
}
})

// Tell Realm to use this new configuration object for the default Realm
Realm.Configuration.defaultConfiguration = config

// Now that we've told Realm how to handle the schema change, opening the file
// will automatically perform the migration
do {
let _ = try Realm()
} catch {
TSLog.error(error as NSError)
}

堆栈跟踪: enter image description here

你知道出了什么问题吗?

最佳答案

如果没有堆栈跟踪中间帧的符号,很难判断,但我怀疑您遇到了 Realm Cocoa issue #2933 ,这似乎是由于 Swift 运行时库中的错误而导致的内存泄漏。

关于ios - iOS Realm 迁移内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39285910/

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