Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - kiffa

Pages: 1 ... 9 10 [11] 12 13 14
151
Support / Re: Memory leak when i tried to switch views.
« on: August 09, 2012, 03:10:14 pm »
With per switch, there will add an extra GLSurfaceView object which have a jpct.VisList objcet of 500K memory usage. I will create a simple test case to check again.

152
Support / Re: How to estimate the memory-usage in jPCT-AE?
« on: August 09, 2012, 03:03:16 pm »
Thanks! Now i got it!

I have read this formular, but i really don't know the memory usage of gpu for textures means "native memory usage" before.

And another question, i know it is not about jPCT, but i really want to get help:

Android 4.0, when my app-process spawned, there were some preload-system-resources(some drawables and other res which were loaded by Zygote, and spawned for each process),  they consumed about 4.1M of memory in my test. I don't use them at all in my app, so i want to free them, but i don't know how to do this.

I have referred the docs of google, and ask this in many forums, but seems not help.

153
I don't see the point of making island and Animated3D.. anyway

1,  There are 2 models in maya : an (bone)animated-dog and a island.  And the dog animates on the island.

2a,  I can exported the dog as .bones and the island as .obj(.ser), but in this way, i need coding their relative position:  dog.translate(x,y,z); island.translate(x1,y1,z1).

2b, I don't want to coding their relative position, i want to do this in maya only. So, i combined the dog and the island to one mesh, exported this mesh to one .bones.  Then i just need translate the combined-one in the world without caring  the relative position of the dog and the island:  combinedMesh.transtale(0, 0, 0);

3, So, is that right?
    a, In "2a", the memory usage is double-dog(Animated3D)  + island(Object3D);
    b, In "2b", the memory usage is double-dog + double-island, because both of them are loaded as Animated3D.

154
Most of my objects are Animated3D :-\. So, they use double memory. Could this be possible: use the Animated3D, but consume almost the same memory of Object3D.

And why there is a copy? Could you implement Animated3D without such a copy(in order to save memory) and without any loss of features、performances and so on.

155
Support / Re: How to estimate the memory-usage in jPCT-AE?
« on: August 07, 2012, 12:22:52 pm »
Thanks!

Before the previous posting, i have tried to search early threads about that in the form, but the result is not good enough for me.

I will try to search again, thanks for your patience!

156
Support / Re: How to estimate the memory-usage in jPCT-AE?
« on: August 07, 2012, 09:05:29 am »
To avoid OOM, the dvm mem limit should >= java mem usage + native mem usage

So i need to know how to estimate both java mem usage and native mem usage.

There are some tools which can report the java mem usage clearly. But i don't know how to estimate the native mem usage. As you say,  "older" vm won't report that.

To resolve OOM, what i do first is to find the component(s) which consumed the most memory, then improve it. 

In short, for my app, the java mem usage is about 11.5M(5M for mesh, 1.5M for animation, 2M for textures, 500K for VisList...). But i have no idea about the native memory usage, so i don't know which one (of mesh、animation、textures) should i decrease first, because i want to get the most benefit of memory-improvement with the least modifying. Does the mesh(Object3D) use the native memory?  Does the animation(bones) use the native memory? Dose the textures use the native memory?

And i want to add some features in my app in future, so i need to know the left mem of vm = vm limit - "java mem used "- "native mem used ".
 

157
Support / Re: How to estimate the memory-usage in jPCT-AE?
« on: August 07, 2012, 07:20:51 am »
Thanks!

Another question: how  to estimate the memory-usage of native in jPCT-AE?

I am marred by OOM. So i tried the MAT(http://www.eclipse.org/mat/) to analyse the memory usage, but seems that it could only be used to analyse java-memory-usage.

I want to know: in jPCT-AE, when and how many native memories will be allocated by who(class.methods) for what?

A general(mainly) description about this is helpful for me, thanks!

158
And how to estimate the memory usage of bones model and animation?

159
I have the models of a dog and an island, and the dog is animated, the island is not.

I combined the island to the dog in maya, so the island will be the sub-meshes of the dog.  And i exported the combined model into only one .mesh.xml, then converted to .bones which named dog.bones(included the dog and the island in fact).

Then, i use BonesIO.loadGroup to load  the dog.bones, and there will create some Animated3D objects, one(the dog) have animation-data, the others have not.

My question is: With the same model, does the Animated3D obj retain more memory than the Object3D?

For examble, with the same island model:
A: The island model(.bones) is loaded into an Animated3D object as a sub-mesh of the animated-dog-model.
B: The island model(.obj or .ser)  is loaded into an Object3D object.
Will "A" retain more memory than "B"?  And if so, about how many than?

160
Support / Re: Memory leak when i tried to switch views.
« on: August 06, 2012, 10:56:20 am »
dispose() definitely isn't useless. Even if you don't see any effect in this situation, it's mandatory to call it before the FrameBuffer goes out of scope. The same is true for world.dispose() in case you are creating a new one.
So, you do this in finalize() and i needn't  to call FrameBuffer.dispose() or world.dispose() manually if i ensure they could be recycled correctly by GC. Is that right?


Do these 500kb add up each time you do the switch or does it happen only once?
Each time.


161
Support / Memory leak when i tried to switch views.
« on: August 06, 2012, 05:19:26 am »
My app has 2 views, the one is SurfaceView, the other is GLSurfaceView. I need switch between them frequently, so i want to just load the models once and keep them in the memory in order to speed up the switching process.

The process:
entry SurfaceView -> switch to GLSurfaceView -> load models -> init world and others -> render and display world -> switch to SurfaceView -> switch to GLSurfaceView -> just use pre-loading models without reloading -> init world and others -> render and display world -> .....

But there seems a memory-leak in my test-app, my codes(some pseudo code):
Code: [Select]
//onSurfaceCreated

if(modelsPreloded)
  use preloadedModels and textures;
else
  loadModels() and initTextures();

initWorldAndOthers();
addAllModelsToWorld();
buildAllObjctes();

// onSurfaceChanged
  mFrameBuffer = new FrameBuffer(width, height);

// onDrawFrame
animate();
mWorld.renderScene(mFrameBuffer);
mWorld.draw(mFrameBuffer);
mFrameBuffer.display();

// onTouchEvent
if(touch down)
  mActivity.setContentView(new MyGLSurfaceView(mActivity));

With per touching down, the memory usage will increase about 500K. But what i expect is that there should be non memory usage increasing when switching from an old GLSurfaceView to the new one.

And if i change code to de-active "mWorld.renderScene(mFrameBuffer)" and "mWorld.draw(mFrameBuffer)", there will no memory usage increase when i touch down:

Code: [Select]
// onDrawFrame
animate();
//mWorld.renderScene(mFrameBuffer);
//mWorld.draw(mFrameBuffer);
mFrameBuffer.display();

Should i do some clear work before switching views? I tried mFrameBuffer.freeMemory() and mFrameBuffer.dispose(), seems useless.

162
Thanks, Egon!

Another questions:

1, You mentioned "newer" vm, my android version is 2.3.3, is this a "newer" vm? And my ADT is the latest version.

2, Does native-buffer have its own limit?  Which i mean is that: if there are 16M free-mems left in vm, then could the max mem of native-buffer be 16M or only be some fixed limit which is smaller than 16M?

3, How many java-mem does world.draw use? How many native-mem does world.draw use? How to roughly estimate this?

4, I read an article from web, which says that: If a block of mem was alloced by java, it will not be reused by native even after this java-mem-block was recycled by GC(because of the mem-caching-mechanism of android).  It not mentioned the version of android.
    I don't know if this option is correct. But if it's correct, some of my doubts will be explained.

5, My codes with some doubts:

 
Code: [Select]
  // new MyRenderer, when running this, free-mem is 3-4M. 
      initWorld();
      initTexture();
      initLight();
      loadModel();
      initCamera();
      initAllAnimations();

 // onSurfaceCreated
      //do nothing

// onSurfaceChanged

      initFrameBuffer(gl, width, height);
      initFpsShown();
      mFpsShown.fpsStart();

      Main3DScene scene = SceneManager.getInstance().buildScene(SceneManager.SCENE_BEGIN, mWorld, mFrameBuffer, mDog);
      SceneManager.getInstance().setCurrentScene(scene);
     
      try
      {
        System.gc();                             
        Log.d("jPCT-AE", "gc");

  // free-mem will jumped from 3M to 12M, which means there are some mem was recycled by GC. So in this point, there was a 12-3=9M mem-increase.
        Thread.sleep(10000);    // waitting for GC     
      }
      catch (InterruptedException e)
      {
        e.printStackTrace();
      }
   

// onDrawFrame
   
      SceneManager.getInstance().getCurrentScene().onDrawFrame(gl);   // will call world.renderScene and world.draw, and the OOM happened here(world.draw).
      mFpsShown.drawFps();
      mFrameBuffer.display();
      mFpsShown.calacFps();
     


My doubt is :
1, When new MyRenderer, DDMS says the free-mem is 3M.
2, When  onSurfaceChanged, there is a mem-increase of 9M by GC. So, there is at least 9M free-mem left.
3, When onDrawFrame, OOM happened, but i don't think 9M is not enough for my situation. Could this happen:
       There are enough mems left in heap, but some of them can't be alloced for native-buffer, so the mem-usage of native is not enough, so the OOM will happen.

163
First i have a animated-obj(.bones) with 1566 frames(24frames/s) animations, with this obj, my code ran fine. And the heap-free-mem was about 11M which was reported by DDMS.

And then i added some more animations to this obj(1566 -> 1755),  with this one, OutOfMemoryError happened.

I don't think  1755 - 1566 = 189 frames-bones-animation will eat 11M of memory.

When i run my app, the heap changed like this:
  first, there was about 3 - 4 M free memory  ---- maybe loading obj...
  then,  the free memory suddenly jumped to 11M.
  then,  OutOfMemoryError happened:

05-13 20:08:31.500: E/AndroidRuntime(4704): java.lang.OutOfMemoryError
05-13 20:08:31.500: E/AndroidRuntime(4704):    at org.apache.harmony.luni.platform.OSMemory.malloc(Native Method)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at org.apache.harmony.luni.platform.PlatformAddressFactory.alloc(PlatformAddressFactory.java:129)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:65)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at java.nio.ReadWriteDirectByteBuffer.<init>(ReadWriteDirectByteBuffer.java:48)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at java.nio.BufferFactory.newDirectByteBuffer(BufferFactory.java:93)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:65)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at com.threed.jpct.GLRenderer.convertTexture(GLRenderer.java:800)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at com.threed.jpct.GLRenderer.setTextures(GLRenderer.java:2270)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:2195)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at com.threed.jpct.World.draw(World.java:1307)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at com.threed.jpct.World.draw(World.java:1074)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at com.zwenyu.scene.Main3DScene.renderWorld(Main3DScene.java:76)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at com.zwenyu.scene.SceneBegin.onDrawFrame(SceneBegin.java:120)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at com.zwenyu.view.Main3DSurfaceView$MyRenderer.onDrawFrame(Main3DSurfaceView.java:376)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)




164
Support / How to estimate the memory-usage in jPCT-AE?
« on: August 02, 2012, 06:20:15 am »
I have read this: http://www.jpct.net/wiki/index.php/Reducing_memory_usage

But i want to know more. Thanks!

 How to estimate the memory-usage of an Object3D obj with some known attributes(such as  triangles、vertexs and so on )? For examble: How many memories will the jPCT-AE allocate when loading a 6000-triangles model? And what's the situation when invoke methods of this Object3D obj?

 How to estimate  the memory-usage of a texture? Is that right: 
 
  1,   By default,  a 256*256 texture will need 256*256*4 bytes memory when "new texture(...)".
  2.a,  If enable "defaultToKeepPixels", there will need another 256*256*4 bytes when "World.draw(...)"(if enable4bpp then will be 256*256*2 bytes).
  2.b,  If disable "defaultToKeepPixels", there will need no extra memory when uploaded to gpu.

  How to estimate the memory-usage of both keyframe-animation and bones-animation?

  What's the situation when i use FrameBuffer.blit(...)?

165
Support / Re: Does jPCT-AE support shadow?
« on: August 02, 2012, 04:53:20 am »
Thanks, Egon! But i really hope you can support this in jPCT-AE. ;D I think it may be helpful for someone.


Take in account Mali-400 does not support high precision floating point number in fragment shader. So if you have some device with Mali-400 or you want full compatibility with this GPUs, you can not use default depth shader. But its easy rewrite them (my rewritten shader is little bit faster). If you want, I can share them. And if you want some numbers, one per-pixel point light, one per-pixel spot light, post-processing image effects (distortion), one rendering of depth buffer, one rendering of motion vectors and motion blur effect (4 samples)... game is running 49fps on Samsung Galaxy S3, without motion blur (and everything needed for this effect) it is 60fps. So your app can running smooth with shadows too. But take in account, this numbers comes from high-end phone.

Thanks, Thomas! Please share them! You can update them to a public-web-store, or send to me by email: kiffa.gx@.gmail.com. Thanks again!

Pages: 1 ... 9 10 [11] 12 13 14