magicalpanda / MagicalRecord

Super Awesome Easy Fetching for Core Data!
Other
10.8k stars 1.79k forks source link

Memory leak importing object when relation key is a UUID #1196

Open mexon opened 8 years ago

mexon commented 8 years ago

I've been debugging memory leaks in our app. I'm fairly sure there's some weird interaction between MagicalRecord and Coredata. Somehow when importing a record with a UUID string as the primary key, the UUID leaks. I traced the string down to where MR_findFirstByAttribute takes ownership when it builds a predicate. If I archive and unarchive the predicate at that point, the unarchived version contains the string that leaks. I can't see anything obviously wrong with what MagicalRecord is doing, but I'm not familiar enough with Coredata internals to be sure.

Please see attached demo app and screenshot of the memory leak debugger. Hopefully that's enough for someone to reproduce the problem.

MRLeakDemo.zip

screen shot 2016-02-17 at 17 34 22