Out-of-memory when loading 3D OBJ model of 5M size. debug shows the dalvik has 50M memory limit, either on emulator or device. I don’t see why this.
mIndicesInt = ByteBuffer.allocateDirect(indices.length * INT_SIZE_BYTES).order(ByteOrder.nativeOrder()).asIntBuffer();
mIndicesInt.put(indices).position(0);
I even increased AVD RAM to 2048M and heap to 1024M, it doesnot help. it always stop with the same numbers:
D/setIndices(2270): Memory: Pss=67.88 MB, Private=66.09 MB, Shared=13.30 MB
D/setIndices(2270): maxMem=50331648
D/setIndices(2270): totalMem=50208736
D/setIndices(2270): freeMem=1963736
The OBJ model contains more than 20 objects. I removed several objects then out-of-memory issue disappears, so this is a memory hard limit issue per process?
Any suggestion on handling it?
Also AVD optioins to increase RAM and heap size has no effect, why?
5M of vertex data is quite a lot for a mobile environment. If you are also loading textures, consider loading only compressed textures. You can also free some resources once they have been moved to the GPU driver. I would prepare your vertex data offline and only load the required data during runtime. Another option is to compute part of the data, or expand it directly at the vertex/fragment shaders (for example generate bitangents at GPU side).