Hello,
So, I'm making a very small puzzle game, which requires loading a ton of images on screen, and when a user aligns them, they get dismissed (removed) and new images are added to the sceen.
Coding wise, nothing special. But I allow the user to go back to the main screen or levels selections, where he can go to another level.
Tha main problem is that every asset loaded into memory isn't freed at all.
I tried writing some code in the deinit, to see if it's correctly called or not, and it's correctly called.
I have no strong reference, and I double check by emptying any var and nilling them in the deinit. I added a method on the main view controller to present a nil scene after I leave the game level, and while it helps a bit, the memory isn't freed at all.
After playing two or three levels, the device becomes impossibly slow and unresponsive.
The culprit seems to be the way I load textures, which I tried many but settlked now for:
SKSpriteNode(texture: SKTextureAtlas(named:).textureNamed())Then I add the node to the scene. And in the deinit, I loop through all the nodes and remove them, then do removeAllActions(), removeAllChildren() and removeFromParent() ... but it still doesn't empty the memory.
Is there any way to free the cache?
- Triggering a memory warning after leaving the level frees about 50% of the memory
- Checking under Instruments reveals no memory leak, although the memory usage climbs indefinitely, and when checking memory, 90% of it is in VM:CoreUI image data, and checking every entry, it's the same [_CSIRenditionBlockData _allocateImageBytes] that comes back.