CFKevinRef / KCOrderedAccessorFix

Fixes "CoreDataGeneratedAccessors" for ordered, to-many relationships.
95 stars 15 forks source link

Fixed memleaks #3

Open StyxUA opened 11 years ago

CFKevinRef commented 11 years ago

Are these leaking in ARC or manual reference counting? I avoided the autoreleasing methods wherever possible. Under ARC, autoreleasing Foundation methods still get dumped into the current autorelease pool instead of going through objc_autoreleaseReturnValue().

Not a huge deal, just wanted to clarify my choices there.

StyxUA commented 11 years ago

In manual reference counting. As you can see, I didn't use release so this patch will work for both ARC and MRC.

StyxUA commented 11 years ago

Ah, excuse me, I got your point. Let me fix this part.

MarkCSmith commented 11 years ago

For an older non-ARC project, I addressed this memory leak issue by turning on ARC just for NSManagedObjectModel+KCOrderedAccessorFix.m

CFKevinRef commented 11 years ago

Thanks for the input, guys. I've suggested the same solution as @MarkCSmith in the README as it doesn't require any code changes.

StyxUA commented 11 years ago

You see, this solution couldn't work in some situations. For example, in my situation, I need to compile GC-compatible code. It is required for ScreenSaver bundles for 10.7, so I can't use ARC at all.

CFKevinRef commented 11 years ago

Ah thanks, I see. My original implementation in manual ref count used local variables and -release as I saw a lot of strings being dumped into the autorelease pool. It should be simple to check for the presence of ARC at compile-time and just define them out.