ios - Memory Leak about for each instance -


sorry,i'm beginner.
don't know how fix memory leak.
use instrument check leak. , find create city model instance, , should recycling memory.
should fix it?
thanks.

class citylist:defaultmodel {      func getcities() {     let query = maindb.city     {         let results = try maindb.db?.prepare(query)         results?.foreach({ (row) in             let cityid = row[schema.cityid.text]             if cityid.isempty == false {                 if let city = self.cities[cityid] {                     city.fromqueryrow(row)                 } else {                     let city = city(cityid) //memory leak                     city.fromqueryrow(row)  //memory leak                     self.cities[cityid] = city                 }             }         })         self.notifysubject.onnext("")     } catch {         debug(object: error)     }  }  } 


class city:nsobject {  let notifysubject = publishsubject<any>()  var id:string = "" @objc var name:string = "" var userid:string = "" var country:string = "" var descriptions:string = ""   override init() {     super.init() }  init(_ id:string) {     super.init()     self.id = id } } 


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -