Hi all =D . I have been facing yet another problem :-? . I have been having heap size problem and found the solution here . It worked and everything was going smoothly, my final heap size change was 800m. The problem started when I distributed the game, when I started the game from .exe it opened and everything is okay, the music is being played the menus are working properly but when I started the game-play I get a warning dialog “OutOfMemoryError: Direct buffer memory” then the game closes. I am running my game on WIndows 7 64bit.
@kamran said: Hi all =D . I have been facing yet another problem :-? . I have been having heap size problem and found the solution here . It worked and everything was going smoothly, my final heap size change was 800m. The problem started when I distributed the game, when I started the game from .exe it opened and everything is okay, the music is being played the menus are working properly but when I started the game-play I get a warning dialog "OutOfMemoryError: Direct buffer memory" then the game closes. I am running my game on WIndows 7 64bit.
Sounds like you are using a HUGE amount of memory. You may want to consider scaling back considerably.
…you can also try lowering the max heap size. Often, increasing this will only make direct memory issues worse since it prevents the GC from running at all… so no direct memory every gets GCed.
@pspeed : I did what you asked me to do. I lowered the heap size to 128m and Direct Memory to 1024 (-Xmx128m -XX:MaxDirectMemorySize=1024m) and ran the .exe file but the same problem still persists. I then thought of removing the heap size value but to keep the DirectMemory value from the VM option and see what happens. The game runs but the same problem remains. I run the game in the SDK with the same settings without heap size and it works.
So then I thought of running the .jar of the game from the command line by giving the DirectMemory value from there and IT WORKED! =D . Then I kept lowering the DirectMemory value and found that the lowest it goes to is 513m. I gave this value in the VM Option. I then ran the game from SDK it worked fine. Then I ran the game from the .exe from the dist but again the problem remain.
It is like .exe is not seeing the DirectMemory value or is not being passed to it. If I run the .jar file through command line with the settings only then it works. Not sure how to fix this.
Just to be clear. I am supposed to clean and build after changing the settings in VM Option, right? because that is what I am doing after each changes and testing the .exe
Sounds like you are running an old version of the SDK from before this bug was fixed.
Yeah, the latest install I did was mid of last year and I have kept on updating it. I am going to download the latest one and see what happens.
@pspeed : Thanks! You are right. It was because of the SDK. Installed the new SDK, upgraded it, needed to make some changes to code and now it works like a charm. I had the 2011 Beta :facepalm: . Everything was working fine with the old SDK except for the OutOfMemory problem. Thanks again @pspeed =D .
Note that -XX options are “subject to change without notice”.
If I understand correctly, that means they might go away or change with any patch release.
The current SDK comes with a bundled JVM, so the SDK should work no matter what.
For distributing your own applications, using -XX (or even -X) will fail if the -XX option went away, so you might consider bundling the JRE yourself. This means you have to include the JRE in your list of components to monitor for security updates (just as with any library you use), so that you can release a security update if necessary.