Hi all:
I used a 2048*2048 jpg for texture, then app crashed. Android-logcat info like this:
07-16 20:36:12.671: I/jPCT-AE(4846): Loading Texture...
07-16 20:36:12.703: D/dalvikvm(4846): GC_FOR_MALLOC freed <1K, 47% free 2921K/5447K, external 9811K/11859K, paused 25ms
07-16 20:36:12.765: I/dalvikvm-heap(4846): Grow heap (frag case) to 30.800MB for 16777232-byte allocation
07-16 20:36:12.796: D/dalvikvm(4846): GC_FOR_MALLOC freed 0K, 12% free 19305K/21895K, external 9811K/11859K, paused 24ms
07-16 20:36:12.820: I/jPCT-AE(4846): Texture loaded...16777216 bytes/2048*2048 pixels!
07-16 20:36:12.906: D/dalvikvm(4846): GC_CONCURRENT freed 1K, 12% free 19304K/21895K, external 9811K/11859K, paused 3ms+4ms
07-16 20:36:13.093: I/jPCT-AE(4846): Memory usage before compacting: 19306 KB used out of 21895 KB. Max. memory available to the VM is 49152 KB.
07-16 20:36:13.132: D/dalvikvm(4846): GC_EXPLICIT freed 1K, 12% free 19306K/21895K, external 9811K/11859K, paused 38ms
07-16 20:36:13.171: D/dalvikvm(4846): GC_EXPLICIT freed <1K, 12% free 19306K/21895K, external 9811K/11859K, paused 38ms
07-16 20:36:13.328: I/jPCT-AE(4846): Memory usage after compacting: 19306 KB used out of 21895 KB. Max. memory available to the VM is 49152 KB.
07-16 20:36:14.132: I/jPCT-AE(4846): Subobject of object 0/object2 compiled to flat fixed point data using 1704 vertices in 230ms!
07-16 20:36:14.140: I/jPCT-AE(4846): Object 0/object2 compiled to 1 subobjects in 808ms!
07-16 20:36:14.140: I/jPCT-AE(4846): Object 'object2' uses one texture set!
07-16 20:36:14.187: D/dalvikvm(4846): GC_EXTERNAL_ALLOC freed 98K, 12% free 19296K/21895K, external 9864K/11859K, paused 41ms
07-16 20:36:14.242: D/dalvikvm(4846): GC_EXTERNAL_ALLOC freed 0K, 12% free 19296K/21895K, external 9864K/11859K, paused 40ms
07-16 20:36:14.273: I/dalvikvm-heap(4846): Clamp target GC heap from 48.845MB to 48.000MB
07-16 20:36:14.289: D/dalvikvm(4846): GC_FOR_MALLOC freed 0K, 12% free 19296K/21895K, external 26248K/28296K, paused 26ms
07-16 20:36:14.382: D/dalvikvm(4846): GC_FOR_MALLOC freed <1K, 12% free 19296K/21895K, external 18056K/26248K, paused 25ms
07-16 20:36:14.382: I/dalvikvm-heap(4846): Forcing collection of SoftReferences for 16777232-byte allocation
07-16 20:36:14.414: D/dalvikvm(4846): GC_FOR_MALLOC freed 0K, 12% free 19296K/21895K, external 18056K/26248K, paused 28ms
07-16 20:36:14.414: E/dalvikvm-heap(4846): Out of memory on a 16777232-byte allocation.
07-16 20:36:14.414: I/dalvikvm(4846): "GLThread 10" prio=5 tid=9 RUNNABLE
07-16 20:36:14.414: I/dalvikvm(4846): | group="main" sCount=0 dsCount=0 obj=0x4051ca80 self=0x2a9410
07-16 20:36:14.414: I/dalvikvm(4846): | sysTid=4855 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=2790728
07-16 20:36:14.414: I/dalvikvm(4846): at com.threed.jpct.GLRenderer.convertTexture(GLRenderer.java:~845)
07-16 20:36:14.414: I/dalvikvm(4846): at com.threed.jpct.GLRenderer.setTextures(GLRenderer.java:2270)
07-16 20:36:14.414: I/dalvikvm(4846): at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:2195)
07-16 20:36:14.414: I/dalvikvm(4846): at com.threed.jpct.World.draw(World.java:1307)
07-16 20:36:14.414: I/dalvikvm(4846): at com.threed.jpct.World.draw(World.java:1074)
07-16 20:36:14.421: I/dalvikvm(4846): at ddd.pd.Demo$MyRenderer.onDrawFrame(Demo.java:231)
07-16 20:36:14.421: I/dalvikvm(4846): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363)
07-16 20:36:14.421: I/dalvikvm(4846): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
07-16 20:36:23.039: W/dalvikvm(4846): threadid=9: thread exiting with uncaught exception (group=0x40015560)
07-16 20:36:23.085: E/AndroidRuntime(4846): FATAL EXCEPTION: GLThread 10
07-16 20:36:23.085: E/AndroidRuntime(4846): java.lang.OutOfMemoryError
07-16 20:36:23.085: E/AndroidRuntime(4846): at com.threed.jpct.GLRenderer.convertTexture(GLRenderer.java:845)
07-16 20:36:23.085: E/AndroidRuntime(4846): at com.threed.jpct.GLRenderer.setTextures(GLRenderer.java:2270)
07-16 20:36:23.085: E/AndroidRuntime(4846): at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:2195)
07-16 20:36:23.085: E/AndroidRuntime(4846): at com.threed.jpct.World.draw(World.java:1307)
07-16 20:36:23.085: E/AndroidRuntime(4846): at com.threed.jpct.World.draw(World.java:1074)
07-16 20:36:23.085: E/AndroidRuntime(4846): at ddd.pd.Demo$MyRenderer.onDrawFrame(Demo.java:231)
07-16 20:36:23.085: E/AndroidRuntime(4846): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363)
07-16 20:36:23.085: E/AndroidRuntime(4846): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
07-16 20:41:23.203: I/Process(4846): Sending signal. PID: 4846 SIG: 9
My code:
//onSurfaceChanged
Options options = new Options();
options.inScaled = false;
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.raw.texture, options);
Texture texture2 = new Texture(bitmap);
TextureManager.getInstance().addTexture("m", texture2);
cube.setTexture("m");
world.addObject(cube);
Can anyone tell me why? And how to resolve it? Why "new Texture(bitmap);" didn't crashed but "World.draw" creashed?
If i use a smaller jpg for texture, then all are ok.