Hi everyone!

I have singleton. It contains a 2 dictionaries. 

struct Stat {
    var statHash:String
    var displayDescription:String
    var displayName:String
    var displayIcon:String
    var statIdentifier:String
}

class Singleton {

    static let sharedInstance = Singleton()

    var statsDesc = [String:Stat]()
    var test = [String: String]()

    init() {
        test["a"] = "b"
    }
}

let singlton = Singleton.sharedInstance
On using the leaks tool, I am getting a memory leak of the second 
dictionary(String, String).

screenshot of memory graph debugger <http://imgur.com/a/JRcGd>

If i remove dictionaries and write smth like that:

class Singleton {
    
    static let sharedInstance = Singleton()
    var num: Int
    
    init() {
        num = 3
    }
}
leak disappears.

Could someone, please, explain why this happens?

Thanks for the help.

Kate
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to