Memory Leak: JSONDecoder.decode

When I run the Profile in Xcode I released that JSONDecoder causing memory leak? The following is the code snippet where the memory leak happens:

if let data = try? JSONSerialization.data(withJSONObject: dict, options: []) {
let decoder = JSONDecoder()
if let decodedObj = try? decoder.decode(T.self, from: data) {
value = decodedObj
}
}

It is a generic class and I believe T isn't causing this. I googled the problem and saw too many issues about memory leak with JSONDecoder of other developers.

try autoreleasepool {
....
}

didn't work.

Have you tried generic functions with JSONDecoder().decode? It seems Swift5 didn't solve the memory leak issue in JSONDecoder.
Any solution to this problem? I am also facing this in swift 5.0


Memory Leak: JSONDecoder.decode
 
 
Q