Java.lang.OutOfMemoryError: Direct buffer memory

hi there, i have a very frustating issue, many times when i use the scene composer and i try to import a model or open the scenecomposer to view a model i get a OutOfMemoryError exception.

i increased the memory in my jmonkeyplatform.conf file, but is useless.
i don’t know what to do, i hope somebody can help me.

this is my configuration:

default_options="–branding jmonkeyplatform -J-Xms128m -J-Xmx512m -J-XX:PermSize=512m -J-XX:MaxDirectMemorySize=2048m"

nd this is the exception trace:

java.lang.OutOfMemoryError: Direct buffer memory
at java.nio.Bits.reserveMemory(Bits.java:658)
at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:123)
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:306)
at com.jme3.util.BufferUtils.createByteBuffer(BufferUtils.java:956)
at com.jme3.scene.plugins.blender.textures.blending.TextureBlenderAWT.blend(TextureBlenderAWT.java:82)
at com.jme3.scene.plugins.blender.textures.CombinedTexture.blend(CombinedTexture.java:260)
at com.jme3.scene.plugins.blender.textures.CombinedTexture.flatten(CombinedTexture.java:153)
at com.jme3.scene.plugins.blender.materials.MaterialContext.applyMaterial(MaterialContext.java:224)
at com.jme3.scene.plugins.blender.meshes.MeshHelper.toMesh(MeshHelper.java:227)
at com.jme3.scene.plugins.blender.objects.ObjectHelper.toObject(ObjectHelper.java:160)
at com.jme3.scene.plugins.blender.AbstractBlenderLoader.toObject(AbstractBlenderLoader.java:137)
at com.jme3.scene.plugins.blender.BlenderLoader.toObject(BlenderLoader.java:71)
at com.jme3.scene.plugins.blender.BlenderModelLoader.load(BlenderModelLoader.java:66)
at com.jme3.scene.plugins.blender.BlenderModelLoader.load(BlenderModelLoader.java:52)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:288)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:374)
at com.jme3.gde.core.assets.SpatialAssetDataObject.loadAsset(SpatialAssetDataObject.java:94)
at com.jme3.gde.core.assets.SpatialAssetDataObject.loadAsset(SpatialAssetDataObject.java:54)
at com.jme3.gde.core.assets.AssetData.loadAsset(AssetData.java:130)
at com.jme3.gde.modelimporter.ModelImporterVisualPanel3.loadModel(ModelImporterVisualPanel3.java:92)
at com.jme3.gde.modelimporter.ModelImporterVisualPanel3.loadSettings(ModelImporterVisualPanel3.java:61)
at com.jme3.gde.modelimporter.ModelImporterWizardPanel3.readSettings(ModelImporterWizardPanel3.java:81)
at org.openide.WizardDescriptor.updateStateOpen(WizardDescriptor.java:865)
at org.openide.WizardDescriptor.updateState(WizardDescriptor.java:820)
at org.openide.WizardDescriptor._updateState(WizardDescriptor.java:798)
at org.openide.WizardDescriptor.goToNextStep(WizardDescriptor.java:1070)
at org.openide.WizardDescriptor.access$1800(WizardDescriptor.java:90)
at org.openide.WizardDescriptor$Listener$1.run(WizardDescriptor.java:2122)
at org.openide.WizardDescriptor.lazyValidate(WizardDescriptor.java:1502)
at org.openide.WizardDescriptor.access$1900(WizardDescriptor.java:90)
at org.openide.WizardDescriptor$Listener.actionPerformed(WizardDescriptor.java:2141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.openide.util.WeakListenerImpl$ProxyListener.invoke(WeakListenerImpl.java:458)
at $Proxy32.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:696)
at java.awt.EventQueue$4.run(EventQueue.java:694)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:154)
at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182)
at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219)
at java.awt.Dialog.show(Dialog.java:1077)
at org.netbeans.core.windows.services.NbPresenter.superShow(NbPresenter.java:1076)
at org.netbeans.core.windows.services.NbPresenter.doShow(NbPresenter.java:1126)
at org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:1098)
at org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:128)
at org.openide.util.Mutex.doEventAccess(Mutex.java:1363)
at org.openide.util.Mutex.readAccess(Mutex.java:273)
at org.netbeans.core.windows.services.NbPresenter.show(NbPresenter.java:1083)
at java.awt.Component.show(Component.java:1651)
at java.awt.Component.setVisible(Component.java:1603)
at java.awt.Window.setVisible(Window.java:1014)
at java.awt.Dialog.setVisible(Dialog.java:1003)
at com.jme3.gde.modelimporter.ImportModel.actionPerformed(ImportModel.java:94)
at org.openide.awt.AlwaysEnabledAction$1.run(AlwaysEnabledAction.java:198)
at org.openide.util.actions.ActionInvoker$1.run(ActionInvoker.java:95)
at org.openide.util.actions.ActionInvoker.doPerformAction(ActionInvoker.java:116)
at org.openide.util.actions.ActionInvoker.invokeAction(ActionInvoker.java:99)
at org.openide.awt.AlwaysEnabledAction.actionPerformed(AlwaysEnabledAction.java:201)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:290)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:696)
at java.awt.EventQueue$4.run(EventQueue.java:694)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

thanks for all answers.

The SDK seems to grab memory and never manages to release it or something. I’ve run into this problem as well and if I have to repeatedly import the same model I almost always have to restart the SDK after four or five imports.

i think is a sdk important issue, because is a great feature, is frustrating restart the sdk many times for a developer, and this can cause to a developer migrate to other graphic engine with a similar feathure.

is my humble opinion.

When you get an outOfMemoryError in Jmonkey, you should listen to it. Reduce the size of your textures, or the amount of vertices. Even if you are able to import a big model, it wouldn’t work well inside the game in real time.

In short, when you get out of memory errors simply get rid of unnecessary fat in your models.

@Pixelapp said: When you get an outOfMemoryError in Jmonkey, you should listen to it. Reduce the size of your textures, or the amount of vertices. Even if you are able to import a big model, it wouldn't work well inside the game in real time.

In short, when you get out of memory errors simply get rid of unnecessary fat in your models.

False. In the SDK, you will get out of memory errors if you just reimport the same model a few times… or view it in the scene viewer a few times.

For some reason, the SDK holds onto direct memory really strongly.

@pspeed What you said is true. But I think my answer actually fits what @eypidemik is experiencing.

@Pixelapp said: @pspeed What you said is true. But I think my answer actually fits what @eypidemik is experiencing.

Well, I suppose it’s up to the OP to clarify but the language he used was “many times when i use the scene composer and i try to import a model”. Key parts I picked up on “many times” and “a model” as opposed to some specific model.

…which implies that sometimes it works and there is no specific model that it fails on consistently. And I experience this exact problem all the time and the next time I will need to import a model I will finally add saving to Script Monkey because it’s just too painful having to restart the SDK all the time. (which OP has also mentioned so presumably that’s also a work-around and an additional clue that it’s not a specific model that never imports.)

But OP should clarify, I guess.