Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios CGImage导致内存泄漏_Ios_Objective C_Xcode_Automatic Ref Counting_Instruments - Fatal编程技术网

Ios CGImage导致内存泄漏

Ios CGImage导致内存泄漏,ios,objective-c,xcode,automatic-ref-counting,instruments,Ios,Objective C,Xcode,Automatic Ref Counting,Instruments,我正在使用以下代码创建cgimage: UIGraphicsBeginImageContext(CGSizeMake(size*2, size*2)); CGContextRef ctx = UIGraphicsGetCurrentContext(); [[SKColor colorWithWhite:0.8 alpha:1] setFill]; CGContextFillEllipseInRect(ctx, CGRectMake(0, 0, size*2, size*2)); UIImag

我正在使用以下代码创建cgimage:

UIGraphicsBeginImageContext(CGSizeMake(size*2, size*2));
CGContextRef ctx = UIGraphicsGetCurrentContext();

[[SKColor colorWithWhite:0.8 alpha:1] setFill];
CGContextFillEllipseInRect(ctx, CGRectMake(0, 0, size*2, size*2));

UIImage *textureImage = UIGraphicsGetImageFromCurrentImageContext();
SKTexture *texture = [SKTexture textureWithImage:textureImage];

SKSpriteNode *node = [SKSpriteNode spriteNodeWithTexture:texture];
显然,这是问题的根源

我试着把它包装在一个自动释放块中,试着释放cgimageref,但我使用的是ARC,所以它们实际上什么都不做。发生了什么事


我想你可能需要打个电话来清理一下

另外,在创建SKTexture对象后,将“
textureImage
”设置为nil,看看这是否有帮助