我的应用程序正在为一个小型应用程序占用大量内存(165MB)。所以我打开了内存调试器,看到了
我是否对此感到好奇?
这是我的Realm对象
class ZoneLevelChild: PersistentObject{
@objc dynamic var childId: String = ""
@objc dynamic var name: String = ""
var children = List<ZoneLevelChild>()
override class func primaryKey() -> String {
return "childId"
}
override func mapping(map: Map) {
childId <- map["ZoneId"]
name <- map["Name"]
children <- (map["Children"], ArrayTransform<ZoneLevelChild>())
}
}
PersistentObject是
class PersistentObject: Object, Mappable {
override var hashValue : Int {
get {
logger.error("Error: PersistentObject hashValue needs to be overriden!")
return 0
}
}
required init(map: Map) {
super.init()
}
required init() {
super.init()
}
required init(realm: RLMRealm, schema: RLMObjectSchema) {
super.init(realm: realm, schema: schema)
}
required init(value: Any, schema: RLMSchema) {
super.init(value: schema, schema: schema)
}
func mapping(map: Map) {}
}
它启用Alamofire和ObjectMapper的映射以及Realm中的持久性。