Slick Forums

Discuss the Slick 2D Library
It is currently Sun May 19, 2013 4:51 pm

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Wed Dec 22, 2010 7:57 pm 
Offline
Oldbie
User avatar

Joined: Fri Jul 20, 2007 9:25 am
Posts: 410
Location: Croatia
Hello,

We released alpha version of the game and gave it to ~10 testers.. for 3 of them game crashed while images were loading (deferred loading) during level loading. I've managed to get error log from one of them:

java.lang.OutOfMemoryError: Direct buffer memory

Can anyone expalain to me why is this happening? I've googled and found out that JVM has a limit of 64MB and my images may exceed that, but why is it happening to only 3 testers and it's fine for us developers and to other 7 testers? Also any idea how to fix it?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 22, 2010 8:15 pm 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
From the jmonkey forum: http://jmonkeyengine.org/groups/general ... er-memory/

Quote:
The issue happens in the running application not jMP.
By default you get 64MB of direct buffer memory, loading a large texture like 4048×4048 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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 22, 2010 9:59 pm 
Offline
Oldbie
User avatar

Joined: Fri Jul 20, 2007 9:25 am
Posts: 410
Location: Croatia
Yes that makes sense. If anyone knows, is it only for single, currently loading image or complete limit to all images ever loaded?
I still don't get how it's working for some, but not others as limit and image size is the same everywhere. I'll report back if it works if my tester retries again with the -XX:MaxDirectMemorySize


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 23, 2010 11:59 am 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
Kova wrote:
I still don't get how it's working for some, but not others as limit and image size is the same everywhere.


Same OS, LJWGL and JRE versions?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 23, 2010 12:32 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1171
Does slick support using PBO to upload textures? these are not counted against the native memory limit.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 23, 2010 3:41 pm 
Offline
Oldbie
User avatar

Joined: Fri Jul 20, 2007 9:25 am
Posts: 410
Location: Croatia
dime wrote:
Kova wrote:
I still don't get how it's working for some, but not others as limit and image size is the same everywhere.

Same OS, LJWGL and JRE versions?


No but that shouldn't matter as JRE is the one imposing the 64MB limit, and all JREs have same 64MB limit since 1.4.2.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 23, 2010 10:01 pm 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
Kova wrote:
dime wrote:
Kova wrote:
I still don't get how it's working for some, but not others as limit and image size is the same everywhere.

Same OS, LJWGL and JRE versions?


No but that shouldn't matter as JRE is the one imposing the 64MB limit, and all JREs have same 64MB limit since 1.4.2.


Yea for the vm; but there is no guarantee that the native lwjgl .dlls allocate the exact same amount of memory in the exact same way across different architects/platforms.

Well, at least that is my theory :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 23, 2010 10:28 pm 
Offline
Oldbie
User avatar

Joined: Fri Jul 20, 2007 9:25 am
Posts: 410
Location: Croatia
dime wrote:
Yea for the vm; but there is no guarantee that the native lwjgl .dlls allocate the exact same amount of memory in the exact same way across different architects/platforms.

Well, at least that is my theory :)


Sounds enough plausible...ok then:
same LWJGL, slick and other libs
different JRE and OS


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 23, 2010 10:53 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1171
dime wrote:
Yea for the vm; but there is no guarantee that the native lwjgl .dlls allocate the exact same amount of memory in the exact same way across different architects/platforms.

Well, at least that is my theory :)


The used native memory is counted by the JVM - it has nothing to do with memory layout etc.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 24, 2010 10:35 am 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
MatthiasM wrote:
dime wrote:
Yea for the vm; but there is no guarantee that the native lwjgl .dlls allocate the exact same amount of memory in the exact same way across different architects/platforms.

Well, at least that is my theory :)


The used native memory is counted by the JVM - it has nothing to do with memory layout etc.


No, I mean if lwjgl has a "load texture"; that internally it has to allocate a bit more housekeeping space, for say linux 64 bit than it does with win 32 bit. It just reports it back to the jvm, there is no way the vm could know or keep track what's being done inside the native functions.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 24, 2010 11:13 am 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1171
Yes, but "java.lang.OutOfMemoryError: Direct buffer memory" only counts the user allocate memory. This is the code from the JRE:
Code:
        synchronized (Bits.class) {
            if (totalCapacity + cap > maxMemory)
                throw new OutOfMemoryError("Direct buffer memory");
            reservedMemory += size;
            totalCapacity += cap;
            count++;
        }

where cap is the user requested size and size is the aligned value of cap. So it only matters how often you have called ByteBuffer.allocateDirect.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 24, 2010 3:51 pm 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
MatthiasM wrote:
Yes, but "java.lang.OutOfMemoryError: Direct buffer memory" only counts the user allocate memory. This is the code from the JRE:
Code:
        synchronized (Bits.class) {
            if (totalCapacity + cap > maxMemory)
                throw new OutOfMemoryError("Direct buffer memory");
            reservedMemory += size;
            totalCapacity += cap;
            count++;
        }

where cap is the user requested size and size is the aligned value of cap. So it only matters how often you have called ByteBuffer.allocateDirect.


ok, that makes sense. I don't know then.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group