Java.lang.OutOfMemoryError: Direct buffer memory

In my laptop the following error occurs.

Spec : Core 2 Duo 1.3, DDR3 2GB, GeForce 210M



what might be the reason?



init:

Deleting: C:UsersIrfanjMonkeyProjectsside_scrollingbuildbuilt-jar.properties

deps-jar:

Updating property file: C:UsersIrfanjMonkeyProjectsside_scrollingbuildbuilt-jar.properties

compile:

run:

Dec 20, 2010 5:43:07 AM com.jme3.system.JmeSystem initialize

INFO: Running on jMonkey Engine 3 Alpha 0.6

Dec 20, 2010 5:43:07 AM com.jme3.system.Natives extractNativeLibs

INFO: Extraction Directory #1: file:/C:/Program%20Files/jmonkeyplatform/jmonkeyplatform/libs/

Dec 20, 2010 5:43:07 AM com.jme3.system.Natives extractNativeLibs

INFO: Extraction Directory #2: C:UsersIrfanjMonkeyProjectsside_scrolling

Dec 20, 2010 5:43:07 AM com.jme3.system.Natives extractNativeLibs

INFO: Extraction Directory #3: C:UsersIrfanjMonkeyProjectsside_scrolling

Dec 20, 2010 5:43:07 AM com.jme3.system.lwjgl.LwjglAbstractDisplay run

INFO: Using LWJGL 2.5

Dec 20, 2010 5:43:07 AM com.jme3.system.lwjgl.LwjglDisplay createContext

INFO: Selected display mode: 800 x 600 x 0 @0Hz

Dec 20, 2010 5:43:08 AM com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: Display created.

Dec 20, 2010 5:43:08 AM com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: Adapter: nvd3dum

Dec 20, 2010 5:43:08 AM com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: Driver Version: 8.17.12.6099

Dec 20, 2010 5:43:08 AM com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: Vendor: NVIDIA Corporation

Dec 20, 2010 5:43:08 AM com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: OpenGL Version: 3.3.0

Dec 20, 2010 5:43:08 AM com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: Renderer: GeForce G210M/PCI/SSE2

Dec 20, 2010 5:43:08 AM com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: GLSL Ver: 3.30 NVIDIA via Cg compiler

Dec 20, 2010 5:43:08 AM com.jme3.system.lwjgl.LwjglTimer

INFO: Timer resolution: 1000 ticks per second

Dec 20, 2010 5:43:08 AM com.jme3.renderer.lwjgl.LwjglRenderer initialize

INFO: Caps: [FrameBuffer, FrameBufferMRT, FrameBufferMultisample, OpenGL20, OpenGL21, OpenGL30, ARBprogram, GLSL100, GLSL110, GLSL120, GLSL130, GLSL140, GLSL150, VertexTextureFetch, TextureArray, TextureBuffer, FloatTexture, FloatColorBuffer, FloatDepthBuffer, PackedFloatTexture, SharedExponentTexture, PackedFloatColorBuffer, TextureCompressionLATC, MeshInstancing, VertexBufferArray]

Dec 20, 2010 5:43:08 AM com.jme3.asset.DesktopAssetManager

INFO: DesktopAssetManager created.

Dec 20, 2010 5:43:08 AM com.jme3.renderer.Camera

INFO: Camera created (W: 800, H: 600)

Dec 20, 2010 5:43:08 AM com.jme3.renderer.Camera

INFO: Camera created (W: 800, H: 600)

Dec 20, 2010 5:43:08 AM com.jme3.input.lwjgl.LwjglMouseInput initialize

INFO: Mouse created.

Dec 20, 2010 5:43:08 AM com.jme3.input.lwjgl.LwjglKeyInput initialize

INFO: Keyboard created.

Dec 20, 2010 5:43:08 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initialize

INFO: Audio effect extension version: 1.0

Dec 20, 2010 5:43:08 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initialize

INFO: Audio max auxilary sends: 2

Dec 20, 2010 5:43:08 AM com.jme3.material.MaterialDef

INFO: Loaded material definition: Default GUI

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Gui Node)

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node attachChild

INFO: Child (Statistics View) attached to this node (Gui Node)

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node detachChildAt

INFO: Child removed.

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node detachChildAt

INFO: Child removed.

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node detachAllChildren

INFO: All children removed.

Dec 20, 2010 5:43:08 AM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Gui Node)

Dec 20, 2010 5:43:08 AM com.jme3.material.MaterialDef

INFO: Loaded material definition: Phong Lighting

Dec 20, 2010 5:43:09 AM com.jme3.scene.Node attachChild

INFO: Child (world-ogremesh) attached to this node (null)

Dec 20, 2010 5:43:09 AM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Root Node)

Dec 20, 2010 5:43:12 AM com.jme3.scene.Node attachChild

INFO: Child (building-ogremesh) attached to this node (null)

Dec 20, 2010 5:43:12 AM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Root Node)

Dec 20, 2010 5:43:13 AM com.jme3.app.Application handleError

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.OutOfMemoryError: Direct buffer memory

at java.nio.Bits.reserveMemory(Bits.java:633)

at java.nio.DirectByteBuffer.(DirectByteBuffer.java:95)

at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:288)

at com.jme3.util.BufferUtils.createByteBuffer(BufferUtils.java:842)

at com.jme3.texture.plugins.AWTLoader.load(AWTLoader.java:99)

at com.jme3.texture.plugins.AWTLoader.load(AWTLoader.java:161)

at com.jme3.texture.plugins.AWTLoader.load(AWTLoader.java:168)

at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:224)

at com.jme3.asset.DesktopAssetManager.loadTexture(DesktopAssetManager.java:263)

at com.jme3.texture.Texture.read(Texture.java:612)

at com.jme3.texture.Texture2D.read(Texture2D.java:185)

at com.jme3.export.binary.BinaryImporter.readObject(BinaryImporter.java:292)

at com.jme3.export.binary.BinaryInputCapsule.readSavable(BinaryInputCapsule.java:451)

at com.jme3.material.MatParam.read(MatParam.java:128)

at com.jme3.material.Material$MatParamTexture.read(Material.java:141)

at com.jme3.export.binary.BinaryImporter.readObject(BinaryImporter.java:292)

at com.jme3.export.binary.BinaryInputCapsule.resolveIDs(BinaryInputCapsule.java:477)

at com.jme3.export.binary.BinaryInputCapsule.readStringSavableMap(BinaryInputCapsule.java:661)

at com.jme3.material.Material.read(Material.java:786)

at com.jme3.export.binary.BinaryImporter.readObject(BinaryImporter.java:292)

at com.jme3.export.binary.BinaryInputCapsule.readSavable(BinaryInputCapsule.java:451)

at com.jme3.scene.Geometry.read(Geometry.java:290)

at com.jme3.export.binary.BinaryImporter.readObject(BinaryImporter.java:292)

at com.jme3.export.binary.BinaryInputCapsule.resolveIDs(BinaryInputCapsule.java:477)

at com.jme3.export.binary.BinaryInputCapsule.readSavableArray(BinaryInputCapsule.java:465)

at com.jme3.export.binary.BinaryInputCapsule.readSavableArrayList(BinaryInputCapsule.java:581)

at com.jme3.scene.Node.read(Node.java:600)

at com.jme3.export.binary.BinaryImporter.readObject(BinaryImporter.java:292)

at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:200)

at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:122)

at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:112)

at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:224)

at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:346)

at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:356)

at mygame.Main.initPlayer(Main.java:110)

at mygame.Main.simpleInitApp(Main.java:102)

at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:186)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:134)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:183)

at java.lang.Thread.run(Thread.java:619)

BUILD SUCCESSFUL (total time: 6 seconds)

You are out of java memory, try raising the mem size for jMP in etc/jmonkeyplatform.conf

The issue happens in the running application not jMP.

By default you get 64MB of direct buffer memory, loading a large texture like 4048x4048 resolution is about 66~ MB which will reach this limit.

You can change the amount of direct memory available by passing the -XX:MaxDirectMemorySize= command to the JVM.

I reduced the image res and it is working now.



@normen: Which value I need to change? I didnt find any 64 which I may increase to something higher.

Oh, it was not in jMP, Momoko is right, it was just your application, sorry.

Momoko_Fan said:
The issue happens in the running application not jMP.
By default you get 64MB of direct buffer memory, loading a large texture like 4048x4048 resolution is about 66~ MB which will reach this limit.
You can change the amount of direct memory available by passing the -XX:MaxDirectMemorySize= command to the JVM.


Now all the textures are 1K*1K, but, still it is showing the same error...i think, the scene has gotten heavier, that's why.
I am passing the following argument
-Xmx128m

And now things runs as it should.I hope this is ok.

Do, I need to increase jvm max memory every time I face this error?
When I want to run(binary) it on another pc do I need to increase their jvm max memory as well?
Is it only about texture? but all the textures are 1K*1K...so, what can i do if i want to run it, without increasing the memory.