[Not Irrlicht/Game related
at all]
During the short period I've been working as a developer for mobile devices (iOS, Android), I've done some memory sensitive apps for the iOS and the older devices pretty much crash and burn when memory usage goes above 10-11 MB which is very little if you think about it. Of course, interanlly, it gives you warnings before that, which you can use to release stuff and so on.
It was a tv-guide app with over 150 channels, each with around 40 programmes a day and the client required that the whole guide should be instantly scrollable with no data loading after first load. Storing the data for that is one thing. Eventually the server response was cut to smallest pieces of data I needed, which was a variable length string of title, an integer of channel ID and 2 doubles for start and end timestamps (20 bytes + size of the string .. 1 byte per char, 15-40 characters per title + string object overhead). That's at least 40 bytes per programme. That's almost 2 megs just in programme data. Getting all that data to render with an adequate speed and storing it in memory was another thing of course, I went with tiled layers which, together with memory, is handled by iOS internally but still, it's not like it uses no resources, oh no.
Anyway, once the app started and reached the splash page with nothing really loaded, memory usage was at 1.6 megs already (Android version of the app in that state used around 3 mb, just sitting there having done nothing.) Then moving into the guide it reached around 5 megs once all the visible channel rows had been rendered. Moving down of course started increasing that bit by bit. If you clicked on the programme, a new view was shown the rest of the programme data was loaded. Again, more memory used up. So on and on.
The way iPhone handles moving between different views is that each view is loaded into the memory when it's first shown but is not removed once it disappears. It's only removed when a memory warning is received and it's not the currently visible one. Still, a pain to handle that and release all the used resources which never seemed to decrease memory usage as much as they had used up .. go figure.
The thing is, once you've been to most of the screens in the app, the memory usage is so high (with all the UI elements and images loaded) the guide view kept crashing when moving up and down a lot. So, yeah, I spent ages trying to keep it from doing that. Luckily the iPhone Simulator has a "Simulate memory warning" functionality. Superb.
Keeping stuff in memory, most of the time is a good thing, unlike Android which pretty much destroys the screen once you move away from it and have to reload it the next time. Funny thing about that, happened to the other Android developer here during the project .. Android *sometimes but not always* before removing the previous screen makes an internal image of that screen so it can quickly show it the next time before drawing the real thing. It does that on most devices I think, but it only causes problems on small devices like HTC Wildfire, where the memory usage is very limited. Anyway, the image needed like 4 megs of memory and the app simply caused a "force close" because Android could not figure out that there's not enough room to fit it. Yeah, instead of not storing the image which is not that necessary anyway it decided crash. So, next time you use some Android app on one of the smallest devices and the app suddenly crashes, it's not always the developers fault. Most of the time it is, but not always
Not sure what the point of all this was, but oh well. Related to that, I'll be very impressed once I see Minecraft run on iOS and Android, seeing that the PC version leaks as hell.