realm/realm-cocoa — pull request #1200 by tgoyne (2014-12-09 01:12:49+00:00)
Title: Fix a memory leak when circularly linked objects are added to a Realm

Set the object and array ivars on objects added to Realms to `nil` after reading the values from them, as otherwise the accessors continue to retain objects which are no longer accessible via the API (since the properties return newly created objects, not the objects from the ivars).

Without this, adding an object graph to a Realm without leaking memory is fairly tricky, as you have to break the cycle by nilling ivars directly, and we don't really want to be encouraging people to set ivars on accessors directly (and we were leaking objects from a few tests).

@alazier