updateGeometry eats up memory

Hi there,

I have a little memory leak and no idea what to do about it. The test code is pretty short:

@Override
    public void simpleInitApp() {
        b = new Box(1, 1, 1);
        Geometry geom = new Geometry("Box", b);

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Blue);
        geom.setMaterial(mat);

        rootNode.attachChild(geom);
    }

    @Override
    public void simpleUpdate(float tpf) {
        //TODO: add update code
        b.xExtent = FastMath.sin(FastMath.nextRandomFloat())+1;
        b.updateGeometry();
        
    }

In the profiler it tells me that the update method is creating more and more float[] / Vector3f objects and never removing them. Am I doing something wrong?

Thanks for looking into this,
Gem

If it was “never” removing them you’d get an out of memory error at some point. Depending on your memory settings the garbage collector might not see a reason to remove them for a while. Best only use a Profiler if you know what you’re doing - are there still references listed by the Profiler? If not they will be removed from memory at some point.

Hi, thanks for your answer. Thats the reason why I used the profiler, because I get an OutOfMemory Error after some time.

What kind of out of memory error? If its direct memory the float arrays and Vector3fs are not your problem, direct memory doesn’t appear in the profiler. You probably have a too large heap compared to your direct memory.

I’ll try to find out - thanks for your hints.