Heavy duty GC going on... problem with heightmaps

Hey,



When I do this:


MidPointHeightMap heightMap = new MidPointHeightMap(256, 1);
Vector3f terrainScale = new Vector3f(1, 0.025f, 1);
TerrainBlock tb = new TerrainBlock("Terrain", heightMap.getSize(), terrainScale, heightMap.getHeightMap(), new Vector3f(0, 0, 0), true);
...



Then launching the project (from eclipse) takes forever (about 5 min). I have -verbose:gc enabled and I notice hundreds, if not thousands of gc lines. Something seriously flawed...perhapse this should be programmed so it reuses existing instances when it loops thousands of times. Creating bunch of new instances every loop = extra work for the gc. This is especially true when I switch on the "clod" parameter.

I think there's a bug in some of the new state code that causes a lot of garbage to be created (seems related to LightState). We'll take a look at this.

LightState was making use of Java's … operator which was causing lots of temp float[] creations.  This is fixed now in cvs.

maybe i understood something wrong about which operator was causing the problem, but the put() operation doesn't return new buffers.

i'm  just curious which operator causes such GC problems (i'd like to avoid such problems myself)

I was playing with the (…) ellipses operator



This allows you to do something like method(float … args)



and pass in (1) or (1,2,3,4)



It comes out as an array in the method.



So, it was creating the array each call. Oh well, we discussed that it could be a problem, but made the code much cleaner. It was an experiment worth trying.

it's a good thing to know (or at least to think about)