Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-9400] Mirror make memory leak if children access to IBOutlet #51866

Closed
swift-ci opened this issue Dec 3, 2018 · 1 comment
Closed

[SR-9400] Mirror make memory leak if children access to IBOutlet #51866

swift-ci opened this issue Dec 3, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Dec 3, 2018

Previous ID SR-9400
Radar None
Original Reporter tarunon (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

Xcode: Version 10.1 (10B61)
Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)
Target: x86_64-apple-darwin17.7.0

Additional Detail from JIRA
Votes 1
Component/s
Labels Bug
Assignee None
Priority Medium

md5: c219864c347f8d4951ad971923882ddc

duplicates:

  • SR-8878 Using Mirror to access a weak reference results in object being retained indefinitely

Issue Description:

Minimum swift code is next one.

import UIKit

class Label: UILabel {
    deinit {
        print("deinit label")
    }
}

class NotLeakViewController1: UIViewController {
    @IBOutlet weak var label: Label!
    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

class NotLeakViewController2: UIViewController {
    var label: Label = Label()
    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(label)
        _ = Array(Mirror(reflecting: self).children) // Iterate mirror children
    }
}

class LeakViewController: UIViewController {
    @IBOutlet weak var label: Label!
    override func viewDidLoad() {
        super.viewDidLoad()
        _ = Array(Mirror(reflecting: self).children) // Iterate mirror children
    }
}
@swift-ci
Copy link
Collaborator Author

swift-ci commented Dec 3, 2018

Comment by Nobuo Saito (JIRA)

Looks this is fixed on #19795

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

1 participant