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-5625] Optional Enum (annotated with @objc) + Mutable Array Leak (Swift 3) #48195

Closed
swift-ci opened this issue Aug 3, 2017 · 3 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Aug 3, 2017

Previous ID SR-5625
Radar https://openradar.appspot.com/33683103
Original Reporter cem (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug
Assignee @slavapestov
Priority Medium

md5: 35cf4dfd70334327afe2879d0c779595

Issue Description:

Summary:
When a Swift class contains an optional Enum property that is marked with @objc, and this same class also contains a mutable (var) array holding at least one element, there is an unexpected memory leak.

Steps to Reproduce:
Steps:

  1. Download the attachment project (EnumMemoryLeak.zip) OR clone if from: https://github.com/Giphy/ios-memory-leak-sample
  2. Open the project in XCode
  3. Command + I
  4. Select Leaks Instrument
  5. Record

You should now encounter leaks.

Expected Results:
No leaks.

Observed Results:
Memory leaking.

Version:
XCode:

  • Version 9.0 beta 4 (9M189t)
    (Same issue on 8.3.3 as well)

Deployment Target:

  • 8.0+

MacOS:

  • Version 10.12.5 (16F73)

Notes:
Work around:

If we convert the optional enum class property to a non-optional, leak will disappear.

// Let's convert the optional property to a non-optional
var leakOptionalEnum: leakingObjCMarkedEnum = .memoryLeakCase

@slavapestov
Copy link
Member

#11341

@swift-ci
Copy link
Collaborator Author

swift-ci commented Aug 4, 2017

Comment by Jared Halpern (JIRA)

Thank you @slavapestov!

@swift-ci
Copy link
Collaborator Author

swift-ci commented Aug 4, 2017

Comment by Cem Kozinoglu (JIRA)

that was fast, thanks @slavapestov

@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. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants