Login Action Required

The NinevehGL Forum uses a new concept of "socialized forum" or as we like to say "Tweet Forum".


Here is the deal:
  1. No new registration is required. Just sign in with your Twitter account and authorize the NinevehGL Forum.
  2. Once you’re in, you'll be able to "Follow a Thread", that means every time that thread receive a new post or update you'll receive a mention on your twitter.
  3. Besides, you can enable "Auto Share", then every new post and/or thread you make will be tweeted on your timeline. (By default, auto-share is enabled only for your threads)

Forum Rules:

1. We understand human comunication can become "hot" sometimes. So some insults and bad words ARE allowed. Just don't push too much being an asshole all the time.

2. SPAMMERS are not allowed. There are penalties for this kind of user and they can be banned forever.

3. You can report other users, if you judge necessary. An user reported many times by many people can also be banned forever. However you can also receive penalties for report deliberately for no apparent reason.

If there is a similar thread title, make sure the other one doesn't already have the answer you're looking for.

This forum uses the BBCode (Bulletin Board Code), here are some instructions:

Bold: [b]text[/b]
Italic: [i]text[/i]
Underline: [u]text[/u]

Code: [code]text[/code]
Quote:
[quote=@username]text[/quote]
[quote]text[/quote]

List:
[ul] [*]item [/ul]
[ol] [*]item [/ol]

URL:
[url]http://url.com[/url]
[url=http://url.com]text[/url]

Image:
[img]http://imageurl.com[/img]

Embed (videos, code, 3D):
[embed]http://url.com[/embed]

Welcome to the NinevehGL's world!
NinevehGL is a 3D engine forged with pure Obj-C.
Welcome to the
Forum!
Hello, Guest.

Your current vote:

You can change your vote many times. But it's still one single vote.

Memory Management Issue
Vote this thread:


@DanieleSirocchi

Posts: 10

NGLNewbie

Fri, Jul 5 2013


Hi,
I'm having issues with memory management and I hope you can help me.

I have 2 question:

  1. I'm using ".obj" which have a size of about 10 mb and they are working good (using directly the ".ngl" files make the loading process quite fast) but, using xCode memory management tool, I've noticed that during the loading process the ram utilized is growing very fast and, sometimes, I have memory warning and then a crash. So my question is: are ".obj" of this size too big or probably I'm doing something wrong in my code ?

  2. I'm loading in NGLCamera 2 different array of ".obj": one is working good with memory, allocating and deallocating correctly. The other one, instead, when I dealloc the UIViewController containing NinevehGL, is causing RAM usage growing every time. Is it possible that the model have some texture mapping (or similar problem) that is causing this issue ? I'm asking this because I've tested the same models without texture and I don't have memory issues, but I don't know if effectively an ".obj" can cause this problem.



Thanks alot in advance.

Regards
100% like this - 1/1

@dineybomfim

Posts: 571

NGLAdmin

Fri, Jul 5 2013


In response to: @DanieleSirocchi

Hello buddy,

You're 100% correct in all your assumptions.

- 10Mb is a big size for a file that is intended to run in mobile. Remember that, is much better loading 100 files of 1 Mb than one single file of 10 Mb. The question is about the available memory to run all the process of loading each file.

- Maybe, textures are cached by NinevehGL considering its names just as the UIKit "imageNamed" method. If you have the same imagem being loaded many times there should be no problem. But releasing it and loading again could be a problem.
0% like this - 0/0

@DanieleSirocchi

Posts: 10

NGLNewbie

Mon, Jul 8 2013


@dineybomfim said:


In response to:@DanieleSirocchi

Hello buddy,

You're 100% correct in all your assumptions.

- 10Mb is a big size for a file that is intended to run in mobile. Remember that, is much better loading 100 files of 1 Mb than one single file of 10 Mb. The question is about the available memory to run all the process of loading each file.

- Maybe, textures are cached by NinevehGL considering its names just as the UIKit"imageNamed" method. If you have the same imagem being loaded many times there should be no problem. But releasing it and loading again could be a problem.


Thanks alot for your reply.

I have 2 more question

What's the best way to manage many different obj ? For example: I have 100 obj to load in many different section of my App but, obviously, I can't keep all them in ram. How can I achieve this if releasing and reloading objects is wrong/could be a problem ?


What's your advice about the maximum size of a single obj to load?


Thanks alot in advance for your patience and advices !
Regards


0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Mon, Jul 8 2013


In response to: @DanieleSirocchi

Hello,

Please, don't misunderstand this point... releasing and reloading the object IS the correct way... updating the same instance of NGLMesh is the wrong way.

This is why NinevehGL works internally with NGL Binary file. For example:
You load an object called "myCircle.obj" for the first time. At this moment, NinevehGL generates a binary file called "myCircle.ngl". Then in your application you release the NGLMesh, completely kill the instance (that means removing it from all cameras it's attached to)... Then later on you create another NGLMesh instance and make it load "myCircle.obj", doesn't matter if at this time your application has restarted or if it's the same run, as NinevehGL has a cache of this file (which is not in ram memory, it lies on the "hard drive") your file now will be loaded 900X faster and using much less memory.

That is it. Your code doesn't change anything from the first load call to the second one, this is just an internal NinevehGL routine.

There is no "maximum" size for 3D files... just keep this in mind: "if you're worried about the maximum size, you already started in the wrong way anyway".

You must work with game techniques for any kind of 3D application in mobiles. This meshes must be very simple, with just few thousands of polygons for each mesh, with very optimized textures (nothing bigger than 512x512), very low polys. Just to give you an idea of how great an application could be following this, games like WOW, Diablo III and COD has hundreds of 3D files, each file with 100-300 kbs, all the textures are under 512x512, many texture atlases. And remember that those games run on powerful desktops and consoles platforms, not on Mobiles.


100% like this - 1/1

Thu, Jul 11 2013


In response to: @dineybomfim

These were extremely helpful insights into loading the models as I have the similar troubles with ARC... Not sure why, but memory doesn't go down when I do this after loading the original mesh:

[_camera removeAllMeshes];
_camera = nil;
_currentModel = nil;

As I understand ARC should put those into a release cycle, but memory stays quite high ~36 MB for 6 mb model, which is very strange. Instruments don't catch leaks in this situation. I have no other cameras or objects, which would retain _currentModel. For NGL files it seems to work fine as memory drops from 7 to 5 mb, which I suppose is similar to what NGL file weighs for such a model. I understand that this can still be a problem from apple side as I run ios7 and xcode5. NinevehGL, I guess, is not supporting iOS7 yet as well. Everything else seems to work just fine and I'm extremely happy with it... Maybe I'll try putting loading process to the main thread or smth...
0% like this - 0/0

Thu, Jul 11 2013


Ok, I played around with this all day, and did not really found a good solution. I thought it is ARC's fault in the first place, so I wrapped code in -fno-objc-arc flag class, which allowed me to call release on the mesh, it did not solve the problem. Then I started running sample import application without ARC for ios5 deployment target (still on xcode5) with just this code:

_mesh = [[NGLMesh alloc] initWithFile:@"vase.dae" settings:settings delegate:nil];
[_mesh release];

Memory is still not freed. From what I understand, even though I release my mesh immediately parsing process retains it somehow as mesh loading process is still running ;/ The thing is that after parsing process is complete, memory is not freed. The same happens if I put [_mesh release] into meshLoadingDidFinish. I'm not sure what happens, I'd really like to hear some more explanations on this.Memory is freed only after restarting the app. Thanks!
0% like this - 0/0

@DanieleSirocchi

Posts: 10

NGLNewbie

Thu, Jul 11 2013


In response to: @dineybomfim

Really thanks alot for you help, advices and patience...I'm quite a noob in the 3D world and I'm learning very much on these forum.

I have one more question, because I still have a problem that I can't understand. I'll explain my problem with an example (that is how is my App actually working).

I have a NGLViewController that manage the 3d rendering using NinevehGL framework. I pass to the view controller a NSString that is the name of a 3d object (I'm using directly .ngl --> much faster :D).

When i pass an object, that I'll call object_1.ngl, with xCode memory management tools opened, i can see iPad ram going up and then, when i dealloc NGLViewController, going back to his original state.

When, instead, i pass object_2.ngl (that have totally different geometry and textures) I have memory issue: when I dealloc the view controller some memory remain allocated and I really can't understand why...I'm doing the same operations done with previous object.

My question: is possible that object_2.ngl has something broken ? or, if NinevehGL can load it, the object is perfectly working and is more possible that I'm doing something wrong in my code?

If it's needed I can share the original .obj without problem.


Thanks again for your time.

Regards
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Thu, Jul 11 2013


In response to: @matas_u

Well buddy,

The memory you're seeing is probably not the mesh it self. It's just the NinevehGL working. Any third party framework will have singleton classes and static memories, it's a normal thing.

NinevehGL will not free that memory because is the necessary amount to it work. It was not made to make tiny things and release it. The main goal is to make great 3D applications with few lines of code. So the NinevehGL will keep alive for the entire application. There is no such idea "releasing everything", it just keep alive, regardless the multithreading or single thread.
100% like this - 1/1

Thu, Jul 11 2013


In response to: @dineybomfim

If this is expected behavior, I'm fine I just had to know this to understand that I'm not making some stupid mistake here. Thanks a lot for this information! I just thought something wrong is happening with memory as program full of ngl files never exceeds ~10 MB memory usage for hundreds load/release cycles and with original meshes even the working memory tends to build up. Lets say 3 upload/release cycles will build up working memory at each cycle for about 5mb from 30 to 45 mb. I think I still do something not quite correct, so I'll investigate that further. Anyhow, again, thanks for wonderful engine! Bye!
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Thu, Jul 11 2013


In response to: @matas_u

Could you please post the Instruments screenshot or send us your project via email indicating what you are suspicious about?

About your memory questions, maybe this video can help you to understand:
http://youtu.be/ViGz59b6ljs?t=1m50s

I'll try to explain it a little more here as well:
Look, the memory and performance are two things crucial for any app, so you can be 100% sure of one thing: we'll take care of it very carefully for you!

Doesn't matter if you load 3 or 300 meshes at once... NinevehGL has an internal queue and 5 temporary loading threads. Your 300 meshes will be distributed in these 5 temporary threads as their internal and individual queues.

After a loading and parsing a file, another temporary thread (called Helper Thread) will upload the textures and vertices to the OpenGL core. Only after that, your mesh is really ready for the Render Thread (this one is a persistent thread that never dies). The Render Thread is probably the one you're seeing as a persistent memory. It will never represent a leak for your application, as any NinevehGL render, even with multiples NGLView and multiple NGLCamera will be rendered inside the single background thread.

Trust in us, it's the best approach to take care of your memory when using a powerful 3D application.
0% like this - 0/0

Fri, Jul 12 2013


In response to: @dineybomfim

Hey! Wow, thanks for such a detailed response. I solved my problem! Basically, there was something quite wrong with Collada and Obj files coming from Rhino5 x64... I sent those files to Blender, exported to obj again and memory issuees are gone. This also reduced the file size ¬two times and increased frame rate a lot... This is just perfect now! After setting variables to nil gets memory back to stable limit around 33mb, which is used by render thread and it does not build up anymore after loading more files. I believe there's no need to send you the screenshots anymore. I even imported the whole huge 3D building project from Revit (through Blender as well), iPad2 shows 20 fps, but geometry loads just fine this is very very exciting thing to me and great news for my app ;P Ok, thanks a lot, I'm going to fill your testers form now
100% like this - 1/1

@dineybomfim

Posts: 571

NGLAdmin

Fri, Jul 12 2013


In response to: @matas_u

Could you please send that original Rhino file for investigation?

About the final fps in iPad, there are things you can do to boost the frame rate. The first thing is turning off the light. (nglGlobalLight) It will probably boost your fps back to 60.

However if you want light effects, you'll need to do texture techniques to render the light on textures.
0% like this - 0/0

Fri, Jul 12 2013


In response to: @dineybomfim

yea, 20 FPS is with antialias4x and it is totally not optimized model. I'll check the light as well, but I just loaded that to see if memory works fine. I'll send you the .dae and .obj files, which I saved with rhino and which did not work correctly for investigation. Should I attach those to email?
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Fri, Jul 12 2013


In response to: @matas_u

By original I meant the OBJ and COLLADA you exported from Rhino. Could you? Would be nice if so.
0% like this - 0/0

@DanieleSirocchi

Posts: 10

NGLNewbie

Sat, Jul 13 2013


@matas_u said:


In response to:@dineybomfim

Hey! Wow, thanks for such a detailed response. I solved my problem! Basically, there was something quite wrong with Collada and Obj files coming from Rhino5 x64... I sent those files to Blender, exported to obj again and memory issuees are gone. This also reduced the file size¬two times and increased frame rate a lot... This is just perfect now! After setting variables to nil gets memory back to stable limit around 33mb, which is used by render thread and it does not build up anymore after loading more files. I believe there's no need to send you the screenshots anymore. I even imported the whole huge 3D building project from Revit(through Blender as well), iPad2 shows 20 fps, but geometry loads just fine this is very very exciting thing to me and great news for my app;P Ok, thanks a lot, I'm going to fill your testers form now


Thanks alot for sharing this...solved my memory management problem just re-exporting models into new obj using Blender.
0% like this - 0/0

Sun, Jul 14 2013


In response to: @DanieleSirocchi

Hey, I'm glad it helped, thanks for bringing this topic up, it was a lucky coincidence to dive into the same thing at the same time and find someone else with the same trouble. Cheers.
0% like this - 0/0

@ManjBOS

Posts: 3

NGLNewbie

Tue, Oct 1 2013


In response to: @matas_u

Hi mate you said it is not working with iOS7. i am having same problem. So did you sort it out? or it is still not working?
0% like this - 0/0
Technology

NinevehGL is a 3D engine built right on top of OpenGL ES and it uses all the programmable pipeline power, making it easy for you to create great application with shaders.

Share on


Follow NinevehGL
Fastest way to contact us:

Copyright © 2011 db-in. All rights reserved.