Animations causing out of memory errors

I have recently started adding animated meshes to a level of my games.

Unfortunately this is causing OpenGL out of memory errors.

I have tried downsizing all textures to 128 x 128 to save as much memory as possible. This has not helped.

My meshes are as low poly as I can realistically make them.

Do I have any other courses of action here other than to remove the animated meshes? Is there some sort of “low quality” setting for animation? Will using fewer frames for animations help?

I have multiple animated meshes, however these errors can still occur with only one animated mesh in the scene.

Thanks in advance.

I should have also mentioned that debugging the app shows 40% of memory free immediately before crashing - but I am assuming this is system memory and the issue is with video memory.

The crashes can occur almost immediately - or not until a few minutes have passed.

I have followed the approach outlined here:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:external:3dsmax

No error(posted) no help :wink:

I assume you have a few thausand geometrys using the animated mesh?
In that case it will have a copy if you do not use hardwareskinning.

Ah yes of course, here is the error:

E/com.jme3.app.AndroidHarness( 6072): SEVERE Exception thrown in Thread[GLThread 9788,5,main]
E/com.jme3.app.AndroidHarness( 6072): com.jme3.renderer.RendererException: An OpenGL error has occurred: out of memory
E/com.jme3.app.AndroidHarness( 6072): at com.jme3.renderer.android.RendererUtil.checkGLError(RendererUtil.java:125)
E/com.jme3.app.AndroidHarness( 6072): at com.jme3.renderer.android.OGLESShaderRenderer.clearBuffers(OGLESShaderRenderer.java:401)
E/com.jme3.app.AndroidHarness( 6072): at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:967)
E/com.jme3.app.AndroidHarness( 6072): at com.jme3.renderer.RenderManager.render(RenderManager.java:1029)
E/com.jme3.app.AndroidHarness( 6072): at com.jme3.app.SimpleApplication.update(SimpleApplication.java:252)
E/com.jme3.app.AndroidHarness( 6072): at com.jme3.app.AndroidHarness.update(AndroidHarness.java:467)
E/com.jme3.app.AndroidHarness( 6072): at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:349)
E/com.jme3.app.AndroidHarness( 6072): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1531)
E/com.jme3.app.AndroidHarness( 6072): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)
E/com.jme3.app.AndroidHarness( 6072):

Yes there are a few thousand vertexes per mesh.

Your suggestion seems to have fixed the out of memory errors - however now the animations are somewhat deformed,

here is the relevant code:

[java]final AnimControl ac = findAnimControl(spatial);

          try {
            // add a skeleton debugger to make bones visible
            final Skeleton skel = ac.getSkeleton();
                
            SkeletonControl skeletonControl = new SkeletonControl(skel);
            spatial.addControl(skeletonControl);
            skeletonControl.setHardwareSkinningPreferred(true);
            // create a channel and start the wobble animation
             channel = ac.createChannel();
            channel.setAnim("walk");
          } catch (final Exception e) {
            e.printStackTrace();
          }[/java]

Ignore last post, this was fixed by changing

[java]SkeletonControl skeletonControl = new SkeletonControl(skel);
spatial.addControl(skeletonControl);
[/java]

to

[java]
SkeletonControl skeletonControl = spatial.getControl(SkeletonControl.class);
skeletonControl.setHardwareSkinningPreferred(true);
[/java]

Thanks for your help!

OK it seems that although these errors are now less frequent, I am still getting them sometimes. Any more tips?

That’s strange I never had this issue.
How long are your animations?

20 - 40 frames.

I also have some redundant animations I am not using. Will it help to remove them?

Does this error only occur when running on Android? What device are you using and what’s the Android version?

Are you loading J3O files on the device or mesh.xml files?

Yes only on android.

I am using a galaxy note 2. Android version 4.3

The meshes are .j3o files, but the skeletons are xml files, as clicking “convert to j3o binary” in the left panel does not seem to convert these files.

@jon81 said: Yes only on android.

I am using a galaxy note 2. Android version 4.3

The meshes are .j3o files, but the skeletons are xml files, as clicking “convert to j3o binary” in the left panel does not seem to convert these files.

…? The skeleton is saved in the j3o as well… You don’t need to load it separately.

I do not perform any extra steps to load the skeleton files, just thought it may be happening behind the scenes.

Any ideas at all?

Ooooh the .j3o files ARE smaller if I take out the redundant animations. Hopefully this will help.

Nope, still getting the error. Guys suggestions please?

How large is the resulting j30 file?

I asssume you cross tested against desktop loading not that it is some bug in a laoder or something else?

One is 447 kb, the other 224 kb

Yes desktop is completely fine.

Hm, is the model textures? does it help to remove the textures? Maybee the android app is only a few kb before crashing already? and the buffers for animation are the last bit necessary to explode?

It does use unshaded textures, but I have downsized them to 128x128. The weird thing is it works fine sometimes but not others.