We are about to switch to a new forum software. Until then we have removed the registration on this forum.
When i use loadShape() and shape() to draw an .obj file, if the obj file is too big, it will present the OutofMemory error running on an android device(but works well in java mode), i wonder how to solve this problem?
Thx for your help!
following is the debug:
FATAL EXCEPTION: GLThread 7896
java.lang.OutOfMemoryError
at processing.opengl.PGraphics3D.createShapeImpl(Unknown Source)
at processing.opengl.PShapeOpenGL.createShape3D(Unknown Source)
at processing.opengl.PShapeOpenGL.copyGroup3D(Unknown Source)
at processing.opengl.PShapeOpenGL.createShape3D(Unknown Source)
at processing.opengl.PGraphics3D.loadShapeImpl(Unknown Source)
at processing.opengl.PGraphicsOpenGL.loadShape(Unknown Source)
at processing.core.PApplet.loadShape(Unknown Source)
at processing.test.sketch_131008ab.sketch_131008ab.setup(sketch_131008ab.java:29)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.opengl.PGL$AndroidRenderer.onDrawFrame(Unknown Source)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1462)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216)
Answers
Android apps have pretty narrow memory limits. These memory limits range from 16MB to 48MB on newer devices. This SO article may shed some light: http://stackoverflow.com/questions/3590443/what-is-the-maximum-memory-limits-per-application-for-android-2-2
Meanwhile your Java-mode sketches may access almost all memory of your laptop (eg. 4GB = 4096Mb). This is why in Java-mode you can run apps which use huge and enourmous data sets, whereas in Android mode you can only run apps which will fit into memory limitations of the phone.
In your case you probably need to "process" your obj-file and reduce it's size. For example you can take only every 10th point of the 3D model and this way you may reduce the size of the model by 90%
@dimkir Thank you for your detailed explanation. I'll try to reduce the size of the model. Having checked that my device is 48MB, I wonder if I can change the approximate per-application memory.
You may want to read this:
http://stackoverflow.com/questions/11275650/how-to-increase-heap-size-of-an-android-application/11275677#11275677
Which tells you to:
1) Open AndroidManifest.xml
2) edit api level to 11+ (eg. 11)
(you will have to make sure that you have at least that or higher level of API installed as part of your android SDK)
3) add parameter largeHeap="true" (google where exactly it should be added to AndroidManifest.xml)
4) Run and hope that it will work :)
maybe http://developer.android.com/reference/android/app/ActivityManager.html#getMemoryClass() will work for you and will tell you your total available memory. (or maybe it wont).
and probably few of these:
https://google.ie/search?q=android+increase+per+application+memory+limit
backpacking a bit on this.... i've tried to incorporate the < activity android:largeHeap="true" into my mainfest but it cannot be accessed. Work around?