Author Topic: getSphere high RAM usage  (Read 735 times)

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
getSphere high RAM usage
« on: September 27, 2012, 10:10:15 am »
I have about 32-50 textured spheres in my scene, they are fairly simple, no shaders (using default jPCT shaders), 256x256 texture sizes (total 5 textures shared).

For some reason when I increase the face count from 16 to 32, RAM usage almost doubles:

no spheres = 26MB/48MB
16 faces = 27MB/48MB
24 faces = 33MB/48MB
32 faces = 41MB/48MB

Surely adding an additional 16 faces per globe (800 extra in total) wouldn't cause such a huge spike?



obj3DMain = Primitives.getSphere(32, fScale); // 16 // 24
obj3DMain.setTexture(sTextureName);
obj3DMain.calcTextureWrapSpherical();
obj3DMain.strip();
obj3DMain.setSpecularLighting(true);
world.addObject(obj3DMain);   


jPCT 1.26 beta
OGL ES2.0
Galaxy Note / Intel Emulator+HAX (same outcome on both)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: getSphere high RAM usage
« Reply #1 on: September 27, 2012, 11:50:27 am »
It's not 16 additional polygons per sphere, it's 2*16*16 = 512 per sphere, i.e. 25.600 additional polygons. The increased memory usage is normal behaviour. If your spheres are all the same except for the scale, consider to clone them all from one base sphere, reuse the mesh and enable shareCompiledData() on them to save huge amounts of memory and maybe increase performance. Scaling can be done by setScale() instead.
« Last Edit: September 27, 2012, 01:19:42 pm by EgonOlsen »

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
Re: getSphere high RAM usage
« Reply #2 on: September 27, 2012, 12:21:41 pm »
Ok will do thanks Egon.