Memory leak in NSString stringWithUTF8String: with ARC enabled

In my application i have enabled the ARC. But in my application following lines gives me memory leaks according to instruments. It is in ios 7.0.

    variables = [[NSMutableArray  alloc] init]; // Leak
    events = [[NSMutableArray  alloc] init]; //Leak
    return self;



But in my app if i do something like below it does not show me any leak. But i can’t add items in to the variables.

  • How do I accept a self-signed SSL certificate using iOS 7's NSURLSession
  • Check if Google Maps App is installed in iOS 6
  • How to get coordinates (CGRect) for the selected text in UIWebView?
  • Best architectural approaches for building iOS networking applications (REST clients)
  • How do I write a 1bpp tiff with libtiff on iOS?
  • Reactive Cocoa 5 and ReactiveSwift network requests handling
  • -(id)init{
        variables = [[[NSMutableArray  alloc] init] copy]; // No Leak
        events = [[[NSMutableArray  alloc] init] copy]; //No Leak
        return self;

    NSString *utfString =[NSString stringWithUTF8String:(const char *)attr->children->content];//Leak

        Class cls = NSClassFromString(className);
        NSObject *object = [[cls alloc]init]; //Leak
        if(cls != nil){
            CFRelease((__bridge CFTypeRef)(cls));
        return object;

    Does anyone has any idea how to fix this?

    Solutions Collect From Internet About “Memory leak in NSString stringWithUTF8String: with ARC enabled”

    My guess right now is that your entire object is leaking, which means that the NSMutableArrays created in -init also leak. The version that calls copy isn’t leaking because the copy is probably returning a singleton instance of NSArray (as there are zero elements in it, and it’s an immutable NSArray, there’s probably a singleton instance for that).