【发布时间】:2017-09-29 21:58:39
【问题描述】:
我的领域发展得如此之快,所以我对内存分配大小有一个例外。我的领域大小约为 3.2 GB,所以我把这个领域的配置来解决这个问题:
let config = Realm.Configuration(
// Set the new schema version. This must be greater than the previously used
// version (if you've never set a schema version before, the version is 0).
schemaVersion: 11,
// Set the block which will be called automatically when opening a Realm with
// a schema version lower than the one set above
migrationBlock: { migration, oldSchemaVersion in
},shouldCompactOnLaunch: {totalBytes, usedBytes -> Bool in
guard totalBytes > 10 * 1024 * 1024 * 1024 else { return false }
guard Double(usedBytes) / Double(totalBytes) < 0.5 else { return false }
print("Should compact Realm database: \(usedBytes) / \(totalBytes)")
return true
})
Realm.Configuration.defaultConfiguration = config
但是,问题仍然存在。我做错了什么?
问候
【问题讨论】: