Author Topic: load md2 model question  (Read 2906 times)

Offline Davi

  • byte
  • *
  • Posts: 33
    • View Profile
load md2 model question
« on: November 10, 2011, 07:20:23 am »
I have load md2 successully,but every time I use code finish my Activity,after that I restart my app,it often crashed. the log is as following:
 
Code: [Select]
11-09 13:57:53.769: E/dalvikvm(25707): Out of memory: Heap Size=24323KB, Allocated=24129KB, Bitmap Size=0KB, Limit=21884KB
11-09 13:57:53.769: E/dalvikvm(25707): Extra info: Footprint=24519KB, Allowed Footprint=24583KB, Trimmed=1060KB
11-09 13:57:53.779: W/dalvikvm(25707): threadid=13: thread exiting with uncaught exception (group=0x40025a70)
11-09 13:57:53.779: E/AndroidRuntime(25707): FATAL EXCEPTION: GLThread 16
11-09 13:57:53.779: E/AndroidRuntime(25707): java.lang.OutOfMemoryError
11-09 13:57:53.779: E/AndroidRuntime(25707): at com.threed.jpct.Mesh.<init>(Mesh.java:141)
11-09 13:57:53.779: E/AndroidRuntime(25707): at com.threed.jpct.Mesh.cloneMesh(Mesh.java:332)
11-09 13:57:53.779: E/AndroidRuntime(25707): at com.threed.jpct.Loader.loadMD2(Loader.java:1328)
11-09 13:57:53.779: E/AndroidRuntime(25707): at com.threed.jpct.Loader.loadMD2(Loader.java:131)
11-09 13:57:53.779: E/AndroidRuntime(25707): at org.opencv.mxrtoolkit.GLLayer.loadModel
   

the jpct-ae log is as following:
Code: [Select]
11-09 14:15:15.149: I/jPCT-AE(25759): Static references cleared...
11-09 14:15:15.529: I/jPCT-AE(25759): Loading Texture...
11-09 14:15:15.539: I/jPCT-AE(25759): Loading file from InputStream
11-09 14:15:15.549: I/jPCT-AE(25759): Expanding buffers...16384 bytes
11-09 14:15:15.549: I/jPCT-AE(25759): Expanding buffers...24576 bytes
11-09 14:15:15.549: I/jPCT-AE(25759): Expanding buffers...32768 bytes
11-09 14:15:15.549: I/jPCT-AE(25759): Expanding buffers...40960 bytes
11-09 14:15:15.549: I/jPCT-AE(25759): Expanding buffers...49152 bytes
11-09 14:15:15.549: I/jPCT-AE(25759): Expanding buffers...57344 bytes
11-09 14:15:15.549: I/jPCT-AE(25759): Expanding buffers...65536 bytes
11-09 14:15:15.549: I/jPCT-AE(25759): Expanding buffers...73728 bytes
11-09 14:15:15.549: I/jPCT-AE(25759): Expanding buffers...81920 bytes
11-09 14:15:15.559: I/jPCT-AE(25759): Expanding buffers...163840 bytes
11-09 14:15:15.639: I/jPCT-AE(25759): Expanding buffers...245760 bytes
11-09 14:15:15.639: I/jPCT-AE(25759): File from InputStream loaded...228764 bytes
11-09 14:15:15.719: I/jPCT-AE(25759): Magic number: 844121161
11-09 14:15:15.719: I/jPCT-AE(25759): Version: 8
11-09 14:15:15.719: I/jPCT-AE(25759): Skin width: 168
11-09 14:15:15.719: I/jPCT-AE(25759): Skin height: 195
11-09 14:15:15.719: I/jPCT-AE(25759): Frame size: 1064
11-09 14:15:15.719: I/jPCT-AE(25759): Number of skins: 0
11-09 14:15:15.719: I/jPCT-AE(25759): Number of Vertices: 256
11-09 14:15:15.719: I/jPCT-AE(25759): Number of Texture coordinates: 348
11-09 14:15:15.719: I/jPCT-AE(25759): Number of triangles: 512
11-09 14:15:15.719: I/jPCT-AE(25759): Number of GL-commands: 2622
11-09 14:15:15.719: I/jPCT-AE(25759): Number of Frames: 198
11-09 14:15:15.719: I/jPCT-AE(25759): Reading Texture coordinates...
11-09 14:15:15.719: I/jPCT-AE(25759): Done!
11-09 14:15:15.719: I/jPCT-AE(25759): Reading polygonal data...
11-09 14:15:15.719: I/jPCT-AE(25759): Done!
11-09 14:15:15.899: I/jPCT-AE(25759): Reading keyframes...
11-09 14:15:15.959: I/jPCT-AE(25759): Done!
11-09 14:15:15.959: I/jPCT-AE(25759): Coverting MD2-format into jPCT-format...
11-09 14:15:16.019: I/jPCT-AE(25759): Processing: stand...
11-09 14:15:16.299: I/jPCT-AE(25759): Processing: run...
11-09 14:15:16.429: I/jPCT-AE(25759): Processing: attack...
11-09 14:15:16.469: I/jPCT-AE(25759): Processing: pain...
11-09 14:15:16.629: I/jPCT-AE(25759): Processing: jump...
11-09 14:15:16.659: I/jPCT-AE(25759): Processing: flip...
11-09 14:15:16.819: I/jPCT-AE(25759): Processing: salute...
11-09 14:15:16.969: I/jPCT-AE(25759): Processing: taunt...
11-09 14:15:17.879: I/jPCT-AE(25759): Processing: wave...
I'm sure some memory is not released when I exist this activity, how to release it use jpct-ae ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: load md2 model question
« Reply #1 on: November 10, 2011, 08:56:09 am »
Memory isn't released by jPCT-AE, it's released by the VM's garbage collector. As long as you are keeping a reference to an instance somewhere, it won't be released. When exiting an Activity, it usually won't be destroyed. Read about Android's Activity management to get a better idea of how this works.
Personally, i'm trying to avoid reloading stuff everytime. That's why the examples usually contain this clumsy hack with the static reference.
Also keep in mind that for the garbage collector

Code: [Select]
blah=new Blah();

isn't equal to

Code: [Select]
blah=null;
blah=new Blah();

In the former case, the old and the new reference coexists until the code has been fully executed. In the latter, the old Blah can be collected by the gc before creating the new one.