Intercept low memory warning
Having an issue on my iPod Touch where when the app hits 16 MB memory used, a low memory warning is sent to SafariMobile. I'm not using web views, so I assume the warning is sent to Safari because webkit is interpreting the javascript?
Anyways, when SafariMobile gets that warning, it closes all windows "except the active one" – whatever that means in terms of the Ti App javascript running – which causes the app to throw an uncaught exception about a missing view and thus crash.
Is there any way I can intercept this warning and do something about it before SafariMobile kills the app js?
My App has a 6 MB database that it reads and writes to on every screen, and when I run the Instruments Apple developer tool, the Titanium framework itself is taking ~ 7 MB of RAM, not leaving much room before I hit the 16 MB warning limit that my iPod Touch has.
One other thing I wonder, I'm not using the entire Titanium Mobile SDK. It's quite extensive, and mainly I just use Titanium.UI, Titanium.Database, Titanium.API, and Titanium.App. But the entire SDK gets compiled into the app… This seems like a waste, especially considering the memory limits of mobile devices. Is it possible to compile my app with only the bits of the SDK that I'm using and leave the rest out?
Just trying to figure out how to get myself a little more headroom… After the database and framework, the 2 MB I'm left with isn't a whole lot of headroom for a transactional app to do it's thing.
2 Answers
-
I have this same issue.
I've read that in Objective C, you can use
-(void)applicationDidReceiveMemoryWarning:(UIApplication *)application
but I'm wondering if there's an event in Titanium that would allow me to detect when memory is getting low.Anyone have any ideas?
-
Sorry, there is no event that is fired when there is a memory warning.