{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-cocoa/issues/2882","labels_url":"https://api.github.com/repos/realm/realm-cocoa/issues/2882/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-cocoa/issues/2882/comments","events_url":"https://api.github.com/repos/realm/realm-cocoa/issues/2882/events","html_url":"https://github.com/realm/realm-cocoa/issues/2882","id":117881191,"number":2882,"title":"Creating model object with init(value:_) causes memory leak with To-Many relationship","user":{"login":"samvanderhyden","id":2964502,"avatar_url":"https://avatars.githubusercontent.com/u/2964502?v=3","gravatar_id":"","url":"https://api.github.com/users/samvanderhyden","html_url":"https://github.com/samvanderhyden","followers_url":"https://api.github.com/users/samvanderhyden/followers","following_url":"https://api.github.com/users/samvanderhyden/following{/other_user}","gists_url":"https://api.github.com/users/samvanderhyden/gists{/gist_id}","starred_url":"https://api.github.com/users/samvanderhyden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samvanderhyden/subscriptions","organizations_url":"https://api.github.com/users/samvanderhyden/orgs","repos_url":"https://api.github.com/users/samvanderhyden/repos","events_url":"https://api.github.com/users/samvanderhyden/events{/privacy}","received_events_url":"https://api.github.com/users/samvanderhyden/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"tgoyne","id":408944,"avatar_url":"https://avatars.githubusercontent.com/u/408944?v=3","gravatar_id":"","url":"https://api.github.com/users/tgoyne","html_url":"https://github.com/tgoyne","followers_url":"https://api.github.com/users/tgoyne/followers","following_url":"https://api.github.com/users/tgoyne/following{/other_user}","gists_url":"https://api.github.com/users/tgoyne/gists{/gist_id}","starred_url":"https://api.github.com/users/tgoyne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgoyne/subscriptions","organizations_url":"https://api.github.com/users/tgoyne/orgs","repos_url":"https://api.github.com/users/tgoyne/repos","events_url":"https://api.github.com/users/tgoyne/events{/privacy}","received_events_url":"https://api.github.com/users/tgoyne/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2015-11-19T18:51:22Z","updated_at":"2015-11-19T19:16:59Z","closed_at":null,"body":"I have two models such as these:\r\n\r\n```swift\r\nclass Person: Object {\r\n    dynamic var name:String = \"\"\r\n}\r\n\r\nclass Dog: Object {\r\n    dynamic var name = \"\"\r\n    dynamic var age = 0\r\n    let owners = List<Person>()\r\n}\r\n```\r\n\r\nSimply creating a dog object like this:\r\n\r\n```swift\r\nlet myOtherDog = Dog(value: [\"name\" : \"Pluto\", \"age\": 3])\r\n```\r\ncauses instruments to report a leak of List<Person> and RLMArray \r\n<img width=\"1396\" alt=\"screen shot 2015-11-19 at 10 22 59 am\" src=\"https://cloud.githubusercontent.com/assets/2964502/11280332/65457916-8eaa-11e5-89da-d8afece0ac9f.png\">\r\n\r\nInstruments does not report a leak when just creating an object using init such as \r\n\r\n```swift \r\nlet myDog = Dog()\r\n```\r\n\r\nExample Project: https://www.dropbox.com/s/kckg4xqv4uhstd3/RealmSwiftLeak.zip?dl=0\r\n\r\nInfo:\r\nRealm (0.96.2)\r\nRealmSwift (0.96.2)\r\nOSX 10.10.5\r\nXCode 7.1\r\nCocoaPods 0.39.0"},"comment":{"url":"https://api.github.com/repos/realm/realm-cocoa/issues/comments/158162535","html_url":"https://github.com/realm/realm-cocoa/issues/2882#issuecomment-158162535","issue_url":"https://api.github.com/repos/realm/realm-cocoa/issues/2882","id":158162535,"user":{"login":"tgoyne","id":408944,"avatar_url":"https://avatars.githubusercontent.com/u/408944?v=3","gravatar_id":"","url":"https://api.github.com/users/tgoyne","html_url":"https://github.com/tgoyne","followers_url":"https://api.github.com/users/tgoyne/followers","following_url":"https://api.github.com/users/tgoyne/following{/other_user}","gists_url":"https://api.github.com/users/tgoyne/gists{/gist_id}","starred_url":"https://api.github.com/users/tgoyne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgoyne/subscriptions","organizations_url":"https://api.github.com/users/tgoyne/orgs","repos_url":"https://api.github.com/users/tgoyne/repos","events_url":"https://api.github.com/users/tgoyne/events{/privacy}","received_events_url":"https://api.github.com/users/tgoyne/received_events","type":"User","site_admin":false},"created_at":"2015-11-19T19:16:59Z","updated_at":"2015-11-19T19:16:59Z","body":"The `[self init]` call in `-[RLMObjectBase initWithValue:schema:]` appears to be the culprit, since it calls `RealmSwift.Object.init()` rather than `-[RLMObjectBase init]`, resulting in the Swift properties getting initialized a second time and the originals being leaked."}}