简体   繁体   中英

didReceiveMemoryWarning capabilities: how much could app do

Well, I want to know about app 'capabilities' when app receives memory warnings.

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
    DDLogVerbose(@"applicationDidReceiveMemoryWarning");
    [self executeTasks];
}

Could bluetooth connections be established? ( [central connectPeripheral:perihperal options:nil] )
Could bluetooth peripherals be scanned? ( scan started at this point )
Which kinds of background tasks could be executed?

My concerns:

I put establishConnections code in this applicationDidReceiveMemoryWarning handler. This code tries to establish connections to peripherals by known uids ( [central connectPeripheral:perihperal options:nil] ). I thought that this functionality could be restricted and app would be rejected.

UPD:

Am I right about core bluetooth long-time usage?

    - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application;      // try to clean up as much memory as possible. next step is to terminate app

So, If background service will be terminated, I can put 'establish connections' code inside didReceiveMemoryWarning preventing loosing connections. After that system kills service and take care about these connections as 'events for reviving my service from sleep when devices appear nearby'

There are a few questions in here. I can only answer the first.

applicationDidReceiveMemoryWarning is what it looks like and nothing more: a message from the operating system that free memory is in short supply. You can do whatever you want in response to it, or nothing at all. You can allocate an array of a million ints if you want.

But when the operating system can no longer allocate your app as much memory as it requires, your app will be terminated. Memory warnings are just a nicety you get before this occurs, and ideally you can take some action to free up memory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM