0

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

堆栈跟踪: 在此处输入图像描述

你知道有什么问题吗?

4

1 回答 1

0

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

于 2016-09-03T17:07:41.453 回答