www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: kiffa on October 11, 2013, 12:36:03 PM

Title: Why did Object3D.shareCompiledData increase the usage of memory?
Post by: kiffa on October 11, 2013, 12:36:03 PM
In my test, when using Object3D.shareCompiledData , the usage of memory will decrease for some Object3Ds but increase for another Object3Ds. I don't know if the format of models will affect this(I use 2 formats: .obj and .ser). I got the result by android's log:

10-13 18:24:54.970: D/dalvikvm(7816): GC_CONCURRENT freed 700K, 47% free 3582K/6727K, external 5000K/5097K, paused 2ms+2ms

And the decreased\increased memory is external memory.

My code:
public static Object3D clone(Object3D src, boolean shareVBO, boolean shareTexture){
    Object3D ret = src.cloneObject();
    if(shareVBO)
      ret.shareCompiledData(src);
    if(shareTexture)
      ret.shareTextureData(src);
    return ret;
  }

for(int i = 0; i < num; ++i){
  clone[i] = clone(srcObj, true, true);
  world.addObject(clone[i]);
}
Title: Re: Why did Object3D.shareCompiledData increase the usage of memory?
Post by: EgonOlsen on October 11, 2013, 08:22:35 PM
There's no obvious reason why this should happen. For objects that share compiled data with others, no native memory will be reserved. I think that this has to be tributed to some strange VM  or GC behaviour. I wouldn't worry about it. There a german saying for such things: "Wer misst, misst Mist"...which basically means something like "The one who measures measures crap"... ;)
Title: Re: Why did Object3D.shareCompiledData increase the usage of memory?
Post by: kiffa on October 12, 2013, 04:57:16 AM
OK, I can accept that. Another question:

If I don't call shareCompiledData(), will the cloned obj share the VBO with the source obj? Or the engine will create new VBOs for each cloned obj?
Title: Re: Why did Object3D.shareCompiledData increase the usage of memory?
Post by: EgonOlsen on October 12, 2013, 08:42:25 AM
It will create a new one. The purpose of shareCompiledData is to prevent this.