Error java.lang.OutOfMemoryError: Direct buffer memory

Hi I´m develop an aplication and I have a problem with the parameter -XX:MaxDirectMemorySize=512m, whit this the aplication starts six times and the seven down, this is the error:

om.jme3.app.Application handleError
GRAVE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,main]
java.lang.OutOfMemoryError: Direct buffer memory
at java.nio.Bits.reserveMemory(Bits.java:632)
at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:97)
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:288)
at com.jme3.util.BufferUtils.createByteBuffer(BufferUtils.java:956)
at com.jme3.texture.plugins.AWTLoader.load(AWTLoader.java:121)
at com.jme3.texture.plugins.AWTLoader.load(AWTLoader.java:191)
at com.jme3.texture.plugins.AWTLoader.load(AWTLoader.java:200)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:282)
at com.jme3.asset.DesktopAssetManager.loadTexture(DesktopAssetManager.java:340)
at com.jme3.asset.DesktopAssetManager.loadTexture(DesktopAssetManager.java:350)
at com.vc3d.jme3d.model.textures.ModelTextureManager.asignarTexturas(ModelTextureManager.java:58)
at com.feria.stand.SensorStand.implementarControles(SensorStand.java:48)
at com.vc3d.jme3d.model.ModelLoaderManager.cargarModelos(ModelLoaderManager.java:85)
at com.vc3d.jme3d.app.ClientApp.loadWorld(ClientApp.java:1161)
at com.vc3d.jme3d.app.ClientApp.initGame(ClientApp.java:1085)
at com.vc3d.network.client.ClientListener$6.call(ClientListener.java:234)
at com.vc3d.network.client.ClientListener$6.call(ClientListener.java:229)
at com.jme3.app.AppTask.invoke(AppTask.java:142)
at com.jme3.app.Application.runQueuedTasks(Application.java:584)
at com.jme3.app.Application.update(Application.java:597)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:230)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:662)

How to do for clear the memory?

thanks for you help…

Are you starting multiple applications within the same JVM instance? Otherwise, I can’t see how the seventh versus the first six will matter.

Hi pspeed…

I start the first, I close and start the second, I close and start the third and so on until the six I get the error … I think that’s why the memory is full, but not as empty…
thanks

Each JVM run should be independent of the others. So I’m not sure what’s causing the problem.

Hi pspeed

please look this video, the instance of JVM is the same:

so I throw the application:

I asked that first and didn’t get a direct answer so I assumed otherwise.

I think you will have to force GC if you want to start multiple applications from the same JVM instance.

P.S.: I see no video.

I was editing a video thanks look up

You may be able to adjust the direct and heap memory settings to help with this but I think pspeed is right, force a full garbage collect before each time you run the application and that should hopefully clear out any allocated direct memory from previous ones.

Either that or spawn a new jvm to run the 3d section and close it down after. That shouldn’t be needed but might be safest.