java.lang.OutOfMemoryError

I get that message when i try to play my game. I have searched the web and found

  1. increase the memory allocated (by using the -Xms and/or -Xmx options to the “java” command)

  2. rewrite your application such that it uses less memory

It is my map image which when i make it to big i get the error. I can play with small maps. I’m programming a 2d game and i make the maps in photoshop. But i dont know what format i should use and bit depth. I want to use big maps but not increase the memory allocated to the java command. Can somone help me find the optimal images i should use, please ?

do u use one image for the whole level? ._o

Is it possible to break up your map into different sections and load and unload them as necessary?

Are there other savings you can make elsewhere - I know having a big image causes you problems, but if you can cut down on sprites or sound data you won’t hit the limit even with a big map.

Ah, and regarding bit depths, simply put the smaller the bit depth, the smaller the image. However, using images with the same bit depth as your display is worthwhile as it creates less work to do by the system.

As for image formats, I’d guess that whatever format you use, by the time it gets loaded into memory it’ll be the same size. However, the data you store in the format is more important - if you’re storing but not using alpha data, using RGB/RGBA images when a greyscale would do (masks etc), or using RGB data when colour-index would be better, you should be able to save a bit more.

thanks for helping. I try to unload my animation pictures i dont need and break up my map in smaller sections.