Author Topic: Too many Objects3D and Java heap space  (Read 3825 times)

Offline volpesfuggente

  • byte
  • *
  • Posts: 8
    • View Profile
Too many Objects3D and Java heap space
« on: August 26, 2010, 02:16:25 pm »
Hello.
I have several problems with my simulator.
I have to create a large number of 3D objects (about 50000).
when the program runs I receive the following error message:

Code: [Select]
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at com.threed.jpct.Vectors.<init>(Unknown Source)
at com.threed.jpct.Object3D.init(Unknown Source)
at com.threed.jpct.Object3D.<init>(Unknown Source)
at com.threed.jpct.Primitives.createLatheObject(Unknown Source)
at com.threed.jpct.Primitives.getEllipsoid(Unknown Source)
at com.threed.jpct.Primitives.getSphere(Unknown Source)
at com.threed.jpct.Primitives.getSphere(Unknown Source)

The Object3D are spheres. I've tryed to use this configuration parameters:
Code: [Select]
Config.glAvoidTextureCopies = true;
Config.saveMemory=true;
Config.maxPolysVisible = 512000;  
Config.useMultipleThreads=true;

I tryed to reduce the number of Objs to 500, but I receive the same error message.
Then, if I set Config.maxPolysVisible = 128000;   (instead of 512000), the program runs, but I receive the WARNING: You've exceeded the configured triangle limit for the visibility list. Consider adjusting Config.maxPolysVisible!

In any case there is no way to get it working with 50000 objects...

Any ideas?
Thanks.
« Last Edit: August 26, 2010, 02:19:12 pm by volpesfuggente »

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
Re: Too many Objects3D and Java heap space
« Reply #1 on: August 26, 2010, 03:41:37 pm »
50,000 3d objects seems like a lot for the default 128 megs(or w/e it is).

Why not increase the heap?
http://hausheer.osola.com/docs/5

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Too many Objects3D and Java heap space
« Reply #2 on: August 26, 2010, 08:01:18 pm »
64mb is default (the 128mb mentioned in the link are wrong IMHO), which is pretty low. Try 512mb or even 1024mb...depending on the memory capacity of your machine. And 50000 objects is pretty high and so is a visibility list of 512000. I suggest to compile the objects (http://www.jpct.net/wiki/index.php/Compiled_objects) if possible, if they can share the same mesh, make them share and if they share and can be compiled, call shareCompiledData(<Object3D>); on them.
Compiled objects are faster and you can reduce the size of the visibility list too, because for compiled objects, it contains only one entry/part, which (for simple objects) is one entry/object in a lot of cases.

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
Re: Too many Objects3D and Java heap space
« Reply #3 on: August 26, 2010, 08:30:28 pm »
Quote
64mb is default
Yeah that's what I thought.

Offline volpesfuggente

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Too many Objects3D and Java heap space
« Reply #4 on: August 27, 2010, 04:00:15 pm »
64mb is default (the 128mb mentioned in the link are wrong IMHO), which is pretty low. Try 512mb or even 1024mb...depending on the memory capacity of your machine. And 50000 objects is pretty high and so is a visibility list of 512000. I suggest to compile the objects (http://www.jpct.net/wiki/index.php/Compiled_objects) if possible, if they can share the same mesh, make them share and if they share and can be compiled, call shareCompiledData(<Object3D>); on them.
Compiled objects are faster and you can reduce the size of the visibility list too, because for compiled objects, it contains only one entry/part, which (for simple objects) is one entry/object in a lot of cases.

I've just use the command compileAndStrip() on my Obj3D...
This command is useful only on OpenGL Renderer, isnt'it?
Up to now, I'm using the software render, but I'm trying to convert to the OpenGL (I've some problems to catch the mouse events. In the software renderer I use the Jframe and it is easy... Any suggestions?)

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
Re: Too many Objects3D and Java heap space
« Reply #5 on: August 27, 2010, 04:05:16 pm »
Quote
Up to now, I'm using the software render, but I'm trying to convert to the OpenGL (I've some problems to catch the mouse events. In the software renderer I use the Jframe and it is easy... Any suggestions?)
Check out the source code of robombs. That should help you heaps.