Singleton design potential leak
Posted
by
iBrad Apps
on Stack Overflow
See other posts from Stack Overflow
or by iBrad Apps
Published on 2012-11-20T04:42:14Z
Indexed on
2012/11/20
4:59 UTC
Read the original article
Hit count: 126
I have downloaded a library off of github and have noticed that in the main singleton of the library there is a possible leak in this bit of code:
+(DDGameKitHelper*) sharedGameKitHelper
{
@synchronized(self)
{
if (instanceOfGameKitHelper == nil)
{
[[DDGameKitHelper alloc] init];
}
return instanceOfGameKitHelper;
}
return nil;
}
Now obviously there is no release or autorelease anywhere so I must do it but how and in what way properly? I have looked at various Singleton design patterns on the Internet and they just assign, in this case, instanceOfGameKitHelper to the alloc and init line.
Anyway how would I properly fix this?
Thanks!
© Stack Overflow or respective owner