Memory consumption of aiProcess_JoinIdenticalVertices

Steven Lu
2013-09-04
2013-09-07
  • Steven Lu
    Steven Lu
    2013-09-04

    Hi. I've successfully incorporated assimp in my iOS 3d model viewer project, and it has been very easy to work with once I got past the initial step of getting it to successfully compile :)

    The only problem I have (which sadly appears to be a big one) is the insane memory consumption of the Join Vertices post process stage.

    The problem isn't so much a memory leak or anything like that, but it is simply that attempting to open a large enough model on these devices will cause the OS to immediately terminate the process simply because of how much memory is temporarily requested. Tested here is a ~1.3M vert model, which actually renders very smoothly (around 10ms per frame, using a dumb shader that computes two point lights!) so the device can clearly handle more geometry. You can see that after the spike to 450MB we are holding steady at under 100MB. This includes the two copies of the mesh held in RAM as well as the copy used by the VBOs for rendering! The device must be well capable of at least displaying >10M vert meshes, putting framerate issues aside.

    See here a screenshot from Instruments:

    screenshot of memory consumption

    450MB is enough to get the OS to consistently send memory warning messages. at about 600MB on this device which has 1GB total, the app will be terminated.

    My question is, do you guys have any pointers on where in the code I should look at to find out how to drive down this memory consumption? I'd like for my app to be as flexible as possible with regard to input files, so simply skipping the step is probably not acceptable.

    Thanks

     
    Last edit: Steven Lu 2013-09-04
  • Steven Lu
    Steven Lu
    2013-09-05

    For example... to merge vertices on a mesh using an angle threshold, it is only necessary to loop over the vertices and mark out the indices of the extraneous verts for the ones that get merged, and write the new merged normal into the remaining vert(s). An index/triangle/face list will need to get allocated, but that, plus possibly a flag list for tracking progress, is the only extra memory that should be needed.

     
    Last edit: Steven Lu 2013-09-05
  • Kim Kulling
    Kim Kulling
    2013-09-05

    Hi,

    that sound serious. You can find the code here: https://github.com/assimp/assimp/blob/master/code/JoinVerticesProcess.cpp

    We haven't optimize this for memory footprint now, so I am quite sure we can getting better. Looking at our spare time feel free to help a little bit :-).

    Kimmi

     
  • Steven Lu
    Steven Lu
    2013-09-07

    If I come up with something that is easy to integrate, I would be glad to contribute it to the project!