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-9282] Weak variables in structs leak on String(describing:) or print #51754

Closed
tellowkrinkle opened this issue Nov 16, 2018 · 1 comment
Closed

Comments

@tellowkrinkle
Copy link

@tellowkrinkle tellowkrinkle commented Nov 16, 2018

Previous ID SR-9282
Radar None
Original Reporter @tellowkrinkle
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug, Leak, Runtime
Assignee None
Priority Medium

md5: 2fe6a872faf2ebd035dd37f74a844177

duplicates:

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

Issue Description:

The following code should print "Deinit!" before exiting. It does print this on the Swift 4.1 Snapshot 2018-05-31 toolchain, but does not on the Swift 4.2 toolchain that ships with Xcode 10.

class DeinitDetector {
    deinit {
        print("Deinit!")
    }
}
struct WeakHolder {
    weak var a: DeinitDetector!
}
do {
    let a = DeinitDetector()
    let b = WeakHolder(a: a)
    let _ = String(describing: b)
}

More info here https://forums.swift.org/t/struct-with-weak-ref-memory-issue/18040

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Nov 16, 2018

Comment by LinQingmo (JIRA)

I tried it with Swift Development Snapshot 2018-11-13 (a), it works properly. So it seems to be fixed.

@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
Projects
None yet
Development

No branches or pull requests

2 participants