1

I'm facing a problem using SceneKit in my iOS app. I have a sceneView showing a 3D model (from a .scn file) that the user can customize changing some details like hair color, eyes color and hair style. What it's happening, is that the memory used by the app goes up to around 250 MB, and it happens exactly when the view starts showing my 3D model.

I programmatically compose the "full" 3D model by adding nodes coming from different scenes. Just to be a bit more clear, I have one .scn containing the body, another .scn containing the hair style and so on. When the view loads up, I just create a "fullModel" that is a SCNNode() running through each node of the various .scn files and adding them to my fullModel node. Then I add the fullNode to my scene.rootnode

I'm new in iOS programming and I tried so long to understand what'a going on, even using XCode Instruments "Allocations" and "Leaks" functionalities but nothing helped.

Any suggestion on what I could try to solve the high memory usage will be very appreciated! Thanks a lot!

  • 1
    HI, 250MB memory usage is not uncommon for SceneKit. It all depends on your Models Mesh size and the size of your Textures. Avoid using Textures greater than 1024x1024 or Models that are greater than 10MB in Size. When you unload your Model and/or Scene Elements the Memory should go down, if not, you have some leaking Memory. – ZAY Jan 21 '21 at 08:20
  • Hi @ZAY and thanks a lot for your answer. Unfortunately my model size is around 40 MB and I really don’t know how to edit it in order to reduce its size. Have you got any suggestion about it? I’ve already tried to unload the model and yes, the memory goes down, so I guess there are no memory leaks at the moment – Davide Dell'Aira Jan 21 '21 at 09:05
  • 1
    A 40MB Model is quite heavy for SceneKit, but not impossible to handle. 250MB Memory consumtion sounds pretty normal in that case. You can reduce the Geometry on your Model with i.Ex. Blender. There are tutorials on how to reduce/decimate the Geometry - BUT keep in mind, this will destroy the surface's texture coordinates. And to restore that properly is de facto impossible without the Original Sources (the Program in which the Model was made). So if you dont have a low-poly model (1-2MB in size) you have a Problem. The only exeption is, if you make your Model one single color. Good luck. – ZAY Jan 21 '21 at 13:20
  • Thanks a lot for your answer! I’ll give it a try! – Davide Dell'Aira Jan 21 '21 at 15:30

0 Answers0