Domanda

I've never had a problem using instruments to detect leaks in my previous apps, but for some reason I can't get it to detect any leaks in my current app. I've even created some leaks just to try to get it to do something. I've tried my app as ARC and non-ARC, but this doesn't change anything. No matter what I do there are no leaks detected.

BTW, this is a cocos3d app; not that this should matter right??

I've gone as far as to follow Ray's tutorial (http://www.raywenderlich.com/23037/how-to-use-instruments-in-xcode) which, when testing the sample code, does cause leaks to be detected. I copied the offending code into my app and tried again, both with the simulator and the device, and still nothing. Here's the code I used to try and create leaks:

- (IBAction)rotateTapped:(id)sender {
    NSLog(@"settingsButtonPushed");

    UIImage *currentImage = _imageView.image;
    CGImageRef currentCGImage = currentImage.CGImage;

    CGSize originalSize = currentImage.size;
    CGSize rotatedSize = CGSizeMake(originalSize.height, originalSize.width);

    CGContextRef context = CGBitmapContextCreate(NULL,
                                                 rotatedSize.width,
                                                 rotatedSize.height,
                                                 CGImageGetBitsPerComponent(currentCGImage),
                                                 CGImageGetBitsPerPixel(currentCGImage) * rotatedSize.width,
                                                 CGImageGetColorSpace(currentCGImage),
                                                 CGImageGetBitmapInfo(currentCGImage));

    CGContextTranslateCTM(context, rotatedSize.width, 0.0f);
    CGContextRotateCTM(context, M_PI_2);
    CGContextDrawImage(context, (CGRect){.origin=CGPointZero, .size=originalSize}, currentCGImage);

    CGImageRef newCGImage = CGBitmapContextCreateImage(context);
    UIImage *newImage = [UIImage imageWithCGImage:newCGImage];

    self.imageView.image = newImage;
}

Here's some code of mine that I've tried to purposefully create leaks (calling multiple times):

// if (! self.robotViewController) {
    robotViewController = [[RobotViewController alloc] initWithNibName:@"RobotViewController" bundle:nil];
    self.robotViewController.glView = self.m_glView;
    self.robotViewController.delegate = self;
// }

This is just driving me crazy at this point. I've got to be just missing something here cuz this just doesn't make sense. Anyone got any suggestions?

È stato utile?

Soluzione

I've finally got leaks being detected in the profiler. My problem was that in my haste to make leaks appear, I commented-out the release of my viewController. At least I think that was it. Basically I alloc a viewController, created a few leaks in the viewController, then dismissed it. Without calling the release, the viewController object was still valid (no dealloc called) and therefore no leaks.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top