I'm perplexed as to how I am to free up memory in scene kit using swift. Whenever I create an SCNNode from a collada file, It imports geometry, creates a physics object, and sets a material from a jpg file. This takes up 10 mb of ram when creating a new object for some reason (even though the files sizes are under 300k), but whatever. Whenever it is removed from the parent node, zero ram frees up, and I do not understand why. What code can I use to TRULY remove the object? I can't find any documentation on the subject. This is just a general question, so no code is needed here.
Asked
Active
Viewed 2,306 times
5
-
Are you using the latest beta? Probably unrelated, but I've hit all sorts of memory warnings when experimenting with Scene Kit, and very light files, in the beta. It's also crashing an enormous amount when playing with the timeline editor and .scn editor. I think it's a real beta, beta, and maybe doesn't do the proper release yet. Also, did you assign the file to a variable/property before then giving that to the node? And, one last thing, there is an uninitialise in Swift... but don't know a lot about it. Just remember seeing it in a WWDC video. – Confused Aug 30 '15 at 11:40
-
It's the latest release. Not beta. version 6.4. I'll keep searching, but there's not a lot of material on the subject that you can find online. – tedesignz Aug 30 '15 at 20:26
2 Answers
5
So I found out what I needed to do was set the texture on my game objects to nil before removing them from the parent. Just as a general rule, I started setting all my textures to nil before deleting the node. Anyway, this solved my memory problem.

tedesignz
- 185
- 1
- 15
-
Cool find. Please file a Radar at https://bugreport.apple.com with your sample project attached. – Hal Mueller Dec 17 '15 at 06:36
1
If the node has a strong reference to it, ARC won't dealloc it. You can either switch the node's declaration to 'weak' property or set to nil any strong reference to the node. Change to weak fix due to the different behavior of 'strong' and 'weak'. While a object has a strong reference (simple var or let are automatically strong) it won't be taken out of memory, even if you use removeFromParent function.

Samuel Cortez
- 158
- 9