Hi.
I am finishing my first J2ME midlet, a simple 2D scroller, using netbeans 6.9. I've learned a lot by doing this and reading this forum.
The problem is that my game uses about 4 MB of heap memory, and crashes in most of cellphones (OutOfMemory). This seemed strange, because the game is simple, uses few images, and the code appears (at least to me) to be 'memory sparing'.
Finally i did a Heap dump and i noted that the most of heap is used by a lot of byte arrays (460! using about 2.5 MB). Those arrays are referenced by 189 ImageData objects, and each of them are referenced finally by an ImageArray referenced by com.sun.midp.chameleon.skins.resources.LoadedSkinResources objects. I have about 5 images loaded at this time, but that LoadedSkinResources object is creating lots of images and wasting the memory.
I've searched about chameleon and found that is some kind of way to make the high level user interface look like the telephone graphic style. I don't want that feature, because i'm using only the GameCanvas, not the forms. Can i prevent that memory wasting??
Here is the relevant part of Heap Dump (at splash screen)
[B number of objects = 460 size = 2529228
javax.microedition.lcdui.ImageData n= 189 size: 6048
javax.microedition.lcdui.Image n = 189 Size: 3024
[Ljavax/microedition/lcdui/Image n= 60 size= 2264
com.sun.midp.chameleon.skins.resources.LoadedSkinResources
Thanks in advance. I'm very confused about this and my game isn't running.

Reply With Quote

