Memory leak in Sprite Kit application

I have a Sprite Kit game that I created in Xcode 5, and when profiling it for leaks using tools, I see that there really are some leaks:

enter image description here

The problem is that I can’t say where in my application this happens, because the “Responsible frame” column does not tell me anywhere in my application.

How can I debug / track the origin of this problem?

Update # 1

There is only one file in which I interact w / CGPath, but I call CGPathRelease

...
CGMutablePathRef path = CGPathCreateMutable();

CGPathMoveToPoint(path, NULL, 0, 0);
CGPathAddLineToPoint(path, NULL, size.width, 0);
CGPathAddLineToPoint(path, NULL, size.width, (upperCount * size.width));
CGPathAddLineToPoint(path, NULL, 0, (upperCount * size.width));

CGPathCloseSubpath(path);

upper.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:path];

CGPathRelease(path);
...        

Update # 2

After switching the right panel in the Tools, I was able to see offensive lines (although I'm still not sure what is wrong here):

The first set of leaks ... enter image description here

The second set of leaks ... enter image description here

+3
2

? SKPhysicsBody bodyWithPolygonFromPath

spritekit SKPhysicsBody ( , bodyWithPolygonFromPath, ).

+2

... , . UIBezierPath .

...

CGMutablePathRef path = CGPathCreateMutable();

CGPathMoveToPoint(path, NULL, 0, 0);
CGPathAddLineToPoint(path, NULL, size.width, 0);
CGPathAddLineToPoint(path, NULL, size.width, (upperCount * size.width));
CGPathAddLineToPoint(path, NULL, 0, (upperCount * size.width));

CGPathCloseSubpath(path);

upper.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:path];

CGPathRelease(path);

...

UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(0, 0)];
[path addLineToPoint:CGPointMake(size.width, 0)];
[path addLineToPoint:CGPointMake(size.width, (upperCount * size.width))];
[path addLineToPoint:CGPointMake(0, (upperCount * size.width))];
[path closePath];

upper.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:path.CGPath];

, . ... : D

, , , .

0

Source: https://habr.com/ru/post/1570743/


All Articles