Author Topic: Why did Object3D.shareCompiledData increase the usage of memory?  (Read 2078 times)

Offline kiffa

  • long
  • ***
  • Posts: 199
    • View Profile
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:
Code: [Select]
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:
Code: [Select]
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]);
}

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Why did Object3D.shareCompiledData increase the usage of memory?
« Reply #1 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"... ;)

Offline kiffa

  • long
  • ***
  • Posts: 199
    • View Profile
Re: Why did Object3D.shareCompiledData increase the usage of memory?
« Reply #2 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Why did Object3D.shareCompiledData increase the usage of memory?
« Reply #3 on: October 12, 2013, 08:42:25 am »
It will create a new one. The purpose of shareCompiledData is to prevent this.