SpriteKit texture memory (RAM) usage optimisation

684 views Asked by At

I am at a loss at how to really judge SpriteKit memory usage for a texture atlas or an image loaded into an SKSpriteNode.

Texturepacker supports RGBA4444 output format for png. However, does spritekit actually load them as 16-bit per pixel or are they always loaded as 32 bit per pixel regardless. When I run sips terminal command on MacOS after I convert the image to RGBA4444 in texture packer, it still says that the png file has 4 samples per bit and 8 bits per sample. Therefore it is still RGBA8888!!.

Also, I do not understand why my game in sprite kit already uses 80mb of memory even though all I am doing is loading a background png image (covering the entire background) of all iOS devices (different resolutions for different devices) and a very small Atlas. according to texture packer, both background image and atlas should be less than 10mb in size in RAM. yet, when I run the game, it is already consuming 80 MB.

SpriteKit is very confusing. In cocos2d, it is very easy to force each image to be loaded as RGBA4444, RGB565...etc. In sprite kit, this only seems possible if you delve deep into OpenGL ES low level calls, which I am not very proficient at.

I would switch to cocos2d but its too late as I already made a lot of progress with spritekit. Also, PVR textures look very bad on spritekit.

In summary, my question is: how do you reduce memory usage for textures in memory in spritekit! I am preloading all textures before the level begins and really they are not a lot of textures.

PS. I am developing for iOS 10 and I have the latest Xcode 8.1

Thanks in advance.

0

There are 0 answers