I am trying to load an imaged based heightmap, which has a total size of 1024, into the scene composer. But whenever I try this, it gives me an
java.lang.OutOfMemoryError: Direct buffer memory exception.
So I searched the forum a bit and found out, that i have to increase the heap space, that is used by the SKD.
So I set the following parameters in the jmonkeyplatform.conf file: -J-Xms24m -J-Xmx1024m -J-XX:PermSize=256m -J-XX:MaxDirectMemorySize=2048m
But it somehow doesn’t work for me. I think 1024m are enough, because when i load the heightmap from my sourcecode, it all works fine, although I have set only 512m in my project properties.
So what am I doing wrong? I’ll be very gratefull if you can give me some tips.
The SDK uses a lot of memory as well, so you have to account for that. Here are my parameters:
default_options="–branding jmonkeyplatform -J-Xms512m -J-Xmx1024m -J-XX:PermSize=512m -J-XX:MaxDirectMemorySize=2048m"
Mine are set in the C:\Program Files\jmonkeyplatform\etc\jmonkeyplatform.conf file
Increasing the IDE memory limits is going to depend on your system memory size at some point. For example, I have Eclipse set at 4096m, and system memory is at 8gb, which runs fine.
I would just increase the memory until it works or the IDE doesn’t, or try to use a smaller heightmap, load it in sections, etc.
Ok, I set it to 4096m and it still doesn’t work.
So you mentioned to load it in sections. Do you mean i load 2 maps with a size of 512 each? And if so how would i do this?
And I have a second question:
I managed to load the map with a size of 512. The scene composer created a myScene.j3o file which i loaded with the asset manager into my game. But wouldn’t the heightmap be just a big model then and all the advantages you have with a heightmap over a big model, as decribed in the HelloTerrain tutorial, are lost?
What advantages are there to a heightmap over a model?
You can load the terrain however you want. The scene composer and terrain editor in the SDK give you tools to position models where you want, and modify the terrain without having to use a heightmap.
Also note the difference between direct memory and normal java memory. A bit unintuitive, you are prone to get direct memory oom’s when you set the java heap too big in comparison.