glebd / cocoafob

A set of registration code generation and verification helpers for Obj-C, Ruby (Potion Store), PHP and FastSpring
Other
469 stars 57 forks source link

Memory Leak in CFobLicVerifier? #22

Open AppTyrant opened 8 years ago

AppTyrant commented 8 years ago

I think there may be a memory leak in CFobLicVerifier when compiled with ARC (I'm running Xcode 7.2.1/ OS X 10.11.3).

@property (retain) __attribute__((NSObject)) SecKeyRef publicKey;

If I take that out, set the publicKey ivar directly and retain it (and release it when I'm done) that seemed to get rid of the leak.

glebd commented 8 years ago

I'll need to investigate, thanks for reporting

R4N commented 7 years ago

@AppTyrant @glebd

I noticed this as well while profiling.

In addition to the purposed adjustment from AppTyrant, another possible solution would be to add an else condition with CFobLicVerifier Lifecycle portion and CFRelease(_publicKey) when compiled with ARC:

#pragma mark -
#pragma mark Lifecycle

#if !__has_feature(objc_arc)
- (void)finalize
{
    self.publicKey = nil;
    [super finalize];
}

- (void)dealloc
{
    self.publicKey = nil;
    self.blacklist = nil;
    [super dealloc];
}
#else
- (void)dealloc
{
    CFRelease(_publicKey);
}
#endif

Let me know if you'd like me to issue a PR.