Bug in LWJGL comunication with JVM?

Started by JudoVana, December 01, 2006, 11:57:45

Previous topic - Next topic

JudoVana

In reference to http://lwjgl.org/forum/viewtopic.php?t=2090, i think there could  be an bug in LWJGL  comunication with JVM.

Edited:{
This is not about this error:
org.lwjgl.opengl.OpenGLException: Out of memory (1285)
But JVM error out of memmory.
}

I create an object which load a lot of images and make a textures (mipmaping and so on...) from them. This object can be very big (no less then 256mb)  I can create More this objects... (2 or thre...) All run fine until i need to repalce them. I can do this.

bigObject1=null;
bigObject2=null;
bigObject3=null;
system.gc() //dosent work in realime....
bigObject1=new BigObject();
bigObject2=new BigObject();
bigObject3=new BigObject();//no memory... WHY!

And then (in creating  bigObject3) the jvm crashes, because out of memory.

When I manualy free the textures:
deletingtextures(bigObject1);
bigObject1=null;
deletingtextures(bigObject2);
bigObject2=null;
deletingtextures(bigObject3);
bigObject3=null;
system.gc()
//no reason, because without textures the objects can have about 1mb
bigObject1=new BigObject();
bigObject2=new BigObject();
bigObject3=new BigObject();

All works ok.

But it seams to me taht this is in contradiction with JVM specification, whitch guarants me, that if system is runing out of memory , the gc is called.

Or I`m absolutly out?

Matzon

Try increasing the VM limits using -X options

JudoVana

Alredy done.. a long ago. -Xmx1g ....

Matzon

OpenGL should switch to system memory when it's full... not sure about NIO buffers tho...

elias

This is probably a problem with direct buffers that are allocated elsewhere than the regular java objects. I've seen this behaviour before, and could only fix this by either:

1. Running a System.gc(); Runtime.getRuntime.runFinalizers(); cycle to make sure all Direct Buffers had the chance to be gc'ed _and_ finalized (native memory freed).
2. Adjust the available Direct Buffer memory with: -XX:MaxDirectMemorySize=<size>

The JVM should really do a better effort to free Direct Buffers before reporting an out of memory exception.

- elias

JudoVana

Wou. An logical solutution. And interest reasons;)  Thanx