i tried cloneObject() & new Object3d(o, reuseMesh=true). Tried primitive.shareCompiledData(each cloned object).
Creation part:
Object3D original = Primitives.getSphere(4, 1);
original.compile();
original.strip();
original.build();
original.rotateY((float) (Math.PI / 4));
short i = 0;
short y = 0;
short z = 0;
short rowCount = 0;
for (int j = 0; j < particles.length; j++) {
ParticlePB particle = new ParticlePB();
Object3D o = new Object3D(original, true);//box.cloneObject();
if (i == inRow) {
i = 0;
++rowCount;
}
original.shareCompiledData(o);
o.strip();
// o.forceGeometryIndices(true);
o.build();
y = (short) (i * moveStep);
z = (short) (rowCount * moveStep);
o.translate(0, y, z);
++i;
particle.setObject3D(o);
particles[j] = particle;
world.addObject(o);
System.out.println(usedMemory());
}
after create each SOUT write:
12-01 18:05:48.775: INFO/System.out(29877): 7857992
12-01 18:05:48.775: INFO/System.out(29877): 7870520
12-01 18:05:48.775: INFO/System.out(29877): 7885464
12-01 18:05:48.775: INFO/System.out(29877): 7898184
12-01 18:05:48.775: INFO/jPCT-AE(29877): Memory usage before compacting: 7714 KB used out of 23399 KB
So each obj ~12k, count of iteration = 500;
after that log write sequence
2-01 18:05:49.495: INFO/jPCT-AE(29877): Subobject of object 5/object7 compiled to flat fixed point data using 96 vertices in 5ms!
12-01 18:05:49.495: INFO/jPCT-AE(29877): Object 5/object7 compiled to 1 subobjects in 12ms!
12-01 18:05:49.495: INFO/jPCT-AE(29877): Object 'object7' uses one texture set!
12-01 18:05:49.495: INFO/jPCT-AE(29877): Subobject of object 6/object8 compiled to flat fixed point data using 96 vertices in 1ms!
12-01 18:05:49.505: INFO/jPCT-AE(29877): Object 6/object8 compiled to 1 subobjects in 8ms!
12-01 18:05:49.505: INFO/jPCT-AE(29877): Object 'object8' uses one texture set!
...
12-01 18:05:50.515: INFO/jPCT-AE(29877): Subobject of object 310/object312 compiled to flat fixed point data using 96 vertices in 1ms!
12-01 18:05:50.515: INFO/jPCT-AE(29877): Object 310/object312 compiled to 1 subobjects in 3ms!
12-01 18:05:50.515: INFO/jPCT-AE(29877): Object 'object312' uses one texture set!
12-01 18:05:50.515: ERROR/dalvikvm-heap(29877): 768-byte external allocation too large for this process.
12-01 18:05:50.515: ERROR/dalvikvm(29877): Out of memory: Heap Size=23399KB, Allocated=8826KB, Bitmap Size=943KB, Limit=21884KB
12-01 18:05:50.515: ERROR/dalvikvm(29877): Trim info: Footprint=23879KB, Allowed Footprint=23879KB, Trimmed=480KB
12-01 18:05:50.515: WARN/OSMemory(29877): External allocation of 768 bytes was rejected
12-01 18:05:50.525: WARN/dalvikvm(29877): threadid=8: thread exiting with uncaught exception (group=0x40025a70)
12-01 18:05:50.535: ERROR/AndroidRuntime(29877): FATAL EXCEPTION: GLThread 9
java.lang.OutOfMemoryError
at org.apache.harmony.luni.platform.OSMemory.malloc(Native Method)
at org.apache.harmony.luni.platform.PlatformAddressFactory.alloc(PlatformAddressFactory.java:150)
at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:66)
at java.nio.ReadWriteDirectByteBuffer.<init>(ReadWriteDirectByteBuffer.java:51)
at java.nio.BufferFactory.newDirectByteBuffer(BufferFactory.java:93)
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:68)
at com.threed.jpct.CompiledInstance.fill(CompiledInstance.java:774)
at com.threed.jpct.Object3DCompiler.compile(Object3DCompiler.java:151)
at com.threed.jpct.World.compile(World.java:2050)
at com.threed.jpct.World.renderScene(World.java:1093)
There are only this objects in world. I think they should not overflow the memory.
What doing when out like "INFO/jPCT-AE(29877): Subobject of object 5/object7 compiled to flat fixed point data using 96 vertices in 5ms!
12-01 18:05:49.495: INFO/jPCT-AE(29877): Object 5/object7 compiled to 1 subobjects in 12ms!" ?