Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 Instruments I see that there are indeed some leaks:

enter image description here

The problem is that I can't tell where in my application this is coming from as the "Responsible Frame" column doesn't point me to anywhere in my application.

How would one go about debugging/tracking the origins of this issue?

Update #1

There is only one file in which I'm interacting w/ CGPath but I am calling 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 toggling open the right panel in Instruments I was able to see the offending lines (although I'm still not sure is wrong here):

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

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

like image 518
Kyle Decot Avatar asked Mar 16 '26 11:03

Kyle Decot


1 Answers

Have you seen this? SKPhysicsBody bodyWithPolygonFromPath memory leaks

Looks like its a spritekit bug in SKPhysicsBody (I would guess it is being retained within bodyWithPolygonFromPath but not released).

like image 74
Edwin Iskandar Avatar answered Mar 18 '26 04:03

Edwin Iskandar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!