I'm having a rather annoying issue with a game i'm developing. It runs on all devices i've tested it on except S40 devices. There, i get "Unable to run application" at roughly the same point every time. It's a rather graphically intensive application bordering on 64k, so i'm guessing it's a memory issue or something. Anyone have any experience with this problem (preferably experience with solving it).
On that note, am i the only one that' really prefer an *accurate* emulator for the nokia devices? Testing on nokia emulators says nothing about actual device compliancy, slightly annoying.
99% of the time, the "Unable to run application" error is displayed because you run out of heap space. The solution is obviously to use less heap space. But another thing to consider is heap fragmentation. This is something that the emulators never seem to face, but it's a major problem with the phones themselves. You have to keep new object instantiation to an absolute minimum, especially with large objects like images. If you have a large image that you need to use during the lifetime of the application (a full screen background for instance), then loading it once at startup and never releasing it, instead of reloading it every time you need it helps. Any object you can reinitialize (mostly game data) instead of throw away and create a new one, do it. Etc, etc, etc.
actually, it starts complaining when i set to 120kb, at 130kb it runs fine. This would suggest that either it uses vastly more heapspace on the S40 (unlikely) or that the problem lies elsewhere. Any idea what else could cause this "Unable to run application" message?
Fragmentation. Like I said, the emulator doesn't seem to emulate the fragmentation that goes on in the devices. The devices have a non-compacting garbage collector, so if you're creating and throwing out object at a high rate the heap ends up looking like swiss cheese and the moment you need to allocate a big enough chunk of memory - BOOM!