I am working with the 3D model and I am using the Scene Kit for rendering and Model I/O for loading the obj file. It works perfectly fine for the small size of obj. But now I have 250MB of file and when It starts loading it takes too much memory and lower end devices are crashing.

How can I read this obj files that is used by the scene kit or any alternate way to read this file? Below is the line of code I used for reading obj file:

MDLAsset *asset = [[MDLAsset alloc]  initWithURL:mapURL];
MDLMesh *object = (MDLMesh*)[asset objectAtIndex:0];

Is there any alternative way to load large obj files?

  • 4
    \$\begingroup\$ use a different format that is much more compact and doesn't need post processing after reading. \$\endgroup\$ – ratchet freak Feb 1 '17 at 15:48
  • \$\begingroup\$ .obj is a horrible, horrible, horrible format - yes, use something that's actually designed to be efficient. \$\endgroup\$ – Maximus Minimus Feb 1 '17 at 16:11
  • 1
    \$\begingroup\$ You could write a converter that saves the .obj's parsed and processed data in a binary format that can be loaded quickly. \$\endgroup\$ – SurvivalMachine Feb 1 '17 at 16:49
  • \$\begingroup\$ Thanks for suggestion but I am new in this field so can you please suggest which formate work best and gives the good performance? \$\endgroup\$ – DeveshM Feb 1 '17 at 17:12
  • \$\begingroup\$ .3ds is the de fraco industry standard format. It's binary and efficient. .obj files are good because any programmer can write a parser just by looking at the ascii. However the point of writing such parser is to convert the obj file into a binary format which can be loaded faster. \$\endgroup\$ – Sanchke Dellowar Feb 1 '17 at 17:26

Finally I resolved issue. Issue is with the Xcode I uninstalled everything and installed again and its stared working perfectly. And also there are some memory leaks in OpenGL so that I released.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.