There are close to 6000 JSON files I am downloading from backend. Later I will parse and insert the same records into RealmDB with below piece of code
let drugMonographURLs = [1.json,2.json,.......6000.json]
var drugs = [RLMDrug]()
drugMonographURLs.forEach { item in
queue.async(group: group) {
do {
let data = try Data(contentsOf: item)
let drug = try JSONDecoder().decode(RLMDrug.self, from: data)
drugs.append(drug)
}
catch {
print(error)
}
}
}
At some point of time app is getting crashed immediately after this line
let drug = try JSONDecoder().decode(RLMDrug.self, from: data)
and getting error saying malloc: double free for ptr 0x7f8d4d1c5e00