You may be able to reduce memory use by combining all your
FlatFields into one large FieldImpl. That is, if T is the
MathType of your FlatFields (assuming they all have the same
MathType), then let (index -> T) be the type of a FieldImpl,
with domain Set Integer1DSet(index, number_of_particles).
Add each FlatField by field.setSample(i, particles[i].sphere_field).
Linking only a single FieldImpl to your Display will save a
lot of memory.
Also, if each FlatField does have the same MathType, re-use
the same MathType rather than reconstructing new ones.
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI 53706
hibbard@xxxxxxxxxxxxxxxxx 608-263-4427 fax: 608-263-6738
On Sun, 14 Apr 2002, Ibrahim Z Mohammad wrote:
> I'm trying to display multiple objects(particles) in the same display
> window. I've used the following code to generate the number of particles I
> particles[i].v = new RealType(Integer.toString(i),null,null);
> particles[i].sphere_func = new FunctionType(xyz, particles[i].v);
> particles[i].sphere_set = new Gridded3DSet(xyz, samples_sphere,
> particles[i].Mfold_sphere, particles[i].Mfold_sphere);
> particles[i].sphere_field = new FlatField(particles[i].sphere_func,
> particles[i].sphere_field.setSamples(values_sphere, false);
> particles[i].sphere_map = new ScalarMap(particles[i].v,
> particles[i].sphere_ref = new DataReferenceImpl("sphere_ref");
> where particles is an array of objects of myClass. So far it all works
> fine, but when I try to add all the references to the display using:
> display.addReference(particles[i].sphere_ref, null);
> I run into memory problems. So far I've succeeded in displaying upto 500
> particles simultaneously, but my program needs to go much further than that.
> I dont think the problem is with having very long arrays, because the first
> part of the code runs through very quickly without any problems (I ran the
> .addReference in a seperate loop to see where the problem was). I'm
> wondering if there is a limit to the number of references you can add to a
> DisplayImpJ3d object? The error I get is OutOfMemoryError <<no stack trace
> I've tried using -Xmx to increase available memory, and I'm also setting the
> objects to 'null' after adding each reference and then running System.gc()
> periodically to force the garbage collector, but all that doesnt seem to
> help much.
> Would appreciate you help.
> Ibrahim Z Mohammad
> * *
> University of Illinois at Urbana-Champaign
> * *