Why does creating and removing SKShapeNode and SKNode repeatedly cause a memory leak?

前端 未结 4 532
迷失自我
迷失自我 2021-02-04 18:48

Using the sprite kit template that comes with Xcode, I modify the scene to be as follows :

#import \"MyScene.h\"

@interface MyScene ()
@property (nonatomic,stro         


        
4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-04 19:23

    This is a bug in sprite kit. The problem isn't just with SKShapeNode, it is also with SKPhysicsBody.

    Creating either a physics body, or a shape, using a CGPath causes a memory leak. You can verify this by commenting out either the physics body, or the shape, and running instruments with leaks, allocations and memory monitor.

    Even if you release the path properly, sprite kit doesn't internally. Nothing you can do!

    Fire up instruments, and watch the memory grow! XD

    EDIT: This bug was present in iOS 7.0. Whether it has been fixed in 7.1 or later is not known to me as I stopped using SpriteKit because of this bug. One can verify if it is fixed by simply testing it.

提交回复
热议问题