Addition of Mem Pool and changes to CLOD

I ran a profiler on TestTerrain and came up with around 3 million Vector3f objects created!! I was like holy cow! A backtrace showed most of them being created in


ClodCreator.getMetric()



So, what I did is I added a class called "MemPool" that looks like this.

public class MemPool {
    private MemPool(){}
    public static Vector3f v3a=new Vector3f();
    public static Vector3f v3b=new Vector3f();
    public static Vector3f v3c=new Vector3f();
    public static Vector3f v3d=new Vector3f();
    public static Vector3f v3e=new Vector3f();
    public static Matrix3f m3a=new Matrix3f();
    public static Matrix3f m3b=new Matrix3f();
    public static Vector2f v2a=new Vector2f();
    public static Vector2f v2b=new Vector2f();
}



and I had ClodCreator use this class's Vector objects. TestTerrain now loads almost twice as fast for me. If you ever happen to need a vector or matrix object just for some temporary math and don't want to clutter your heap by creating a new one, try using the MemPool objects. The only problem with this is that it isn't thread safe, but jME wasn't suppose to be thread safe anyways. Let me know what you think about it.

Can’t wait to try that out… awesome enhancement.



Have you run your profiler on it again, by any chance?





–K

Yea. The only object being created too much now is int[], but it’s a bit more complicated to fix. I’m thinking up ideas.

"Cep21" wrote:
Yea. The only object being created too much now is int[], but it's a bit more complicated to fix. I'm thinking up ideas.

We could try crating the terrain from points.


     Vecter3f pounts[]=new Vecter3f[3];
     pounts[0]=new Vecter3f(0,34,13);
     pounts[1]=new Vecter3f(-45,-80,2);
     pounts[1]=new Vecter3f(-45,47,-82);
     //use the pounts to create the terrain  without a hightmap


This could fix the problem.