Too many Objects3D and Java heap space

Started by volpesfuggente, August 26, 2010, 02:16:25 PM

Previous topic - Next topic

volpesfuggente

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:

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:
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.

zammbi

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

EgonOlsen

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.

zammbi

Quote64mb is default
Yeah that's what I thought.

volpesfuggente

Quote from: EgonOlsen 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.

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?)

zammbi

QuoteUp 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.