领域迁移内存泄漏iOS

时间:2016-09-02 06:44:58

标签: ios swift memory-leaks realm realm-migration

我在使用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

你知道出了什么问题吗?

1 个答案:

答案 0 :(得分:0)

在没有符号的情况下很难判断堆栈跟踪的中间帧,但我怀疑你是否遇到Realm Cocoa issue #2933,这似乎是因为一个错误导致的内存泄漏Swift的运行时库。