Navigation Menu

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-3661] Memory Leak from Multiple Dictionary Properties #46246

Closed
swift-ci opened this issue Jan 18, 2017 · 6 comments
Closed

[SR-3661] Memory Leak from Multiple Dictionary Properties #46246

swift-ci opened this issue Jan 18, 2017 · 6 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself memory leak bug: Memory leak

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-3661
Radar rdar://problem/30080079
Original Reporter coreywatson (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Leak
Assignee coreywatson (JIRA)
Priority Medium

md5: dbd590d1a430e99c3212739ce05424c7

Issue Description:

Instantiate a class with more than one dictionary property and a leak will be triggered in libswiftCore.dylib.

class ViewController: UIViewController {

    var dictionaryOne: [Int : String] = [:]
    
    var dictionaryTwo: [Int : String] = [:]

}

The leaked objects are _NativeDictionaryStorageOwner<Int, String> and _NativeDictionaryStorageImpl<Int, String>.

Only one dictionary property will not produce the memory leak, but add one more and it will.

This memory leak is small, but can add up over time, especially with many objects that need multiple dictionary properties. And it makes tracking down other leaks in Instruments an absolute mess.

@belkadan
Copy link
Contributor

@jckarter, any ideas?

@jckarter
Copy link
Member

@swift-ci create

@jckarter
Copy link
Member

@belkadan You know if there's anything unusual about the inherited implementation of `initWithCoder:` that might interfere with our usual Swift init codegen?

@belkadan
Copy link
Contributor

Can't think of anything that would only leak one of the dictionaries. Double initialization due to improperly annotated designated initializers should always leak both of them.

@jckarter
Copy link
Member

jckarter commented Feb 2, 2017

coreywatson (JIRA User) I gave this a shot with Xcode 8.3 beta 1, and I wasn't able to reproduce. I made a fresh Single View Application iOS App, pasted in your view controller definition from the bug report:

import UIKit

class ViewController: UIViewController {

  var dictionaryOne: [Int : String] = [:]
  
  var dictionaryTwo: [Int : String] = [:]
}

Running in the Simulator with the Leaks instrument doesn't register any leaks for me with either one or two dictionaries. Are you able to reproduce in 8.3 beta 1, and if so, would you be able to attach a complete project?

@swift-ci
Copy link
Collaborator Author

Comment by Corey Watson (JIRA)

Looks like beta 1 plugged the leak, and beta 2 plugged a similar one when I attempted to modify dictionaryTwo. Thanks!

@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 memory leak bug: Memory leak
Projects
None yet
Development

No branches or pull requests

3 participants