Heavy CPU processing to heat up the device

My company has created an enterprise application that is used in the field.

We found that our iPhone 5 is not working properly below 0 * C.

One solution we are trying to experiment with is to perform heavy CPU intensive tasks (which is equivalent to running a 3D game), which will add heat to the device (outside of the other external heat we use to help them).

Using the indoor laser temperature gauge as a baseline, I measured 24 * C on the iPhone 5's screen when it was idle on the app's home screen. When I run an intense 3D game, the phone heats up and the screen registers 35 * C for a few minutes.

How can we recreate an intensive background cpu process that does not consume resources or crash the application? I've tried various open source iOS testing apps from GitHub, but when I put them in an infinite loop on a background thread, after a few minutes the app goes out of memory and crashes.

Here is an example of one of the tests that I put on the back burner in an infinite loop. (while 1 = 1). Regardless of which test code I try, "Total Bytes" will grow non-stop until the application crashes. Click to see a screenshot of the tools .

Does anyone have examples of a code intensive processor that I could use to keep the device nice and hot and also prevent the application from wasting resources indefinitely?

Draining the battery is not a problem as we will be using external rechargeable batteries connected to compensate for any leakage.

All help is appreciated!

Adam

    UIApplication * application = [UIApplication sharedApplication];

if([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)])
{
    NSLog(@"Multitasking Supported");

    __block UIBackgroundTaskIdentifier background_task;
    background_task = [application beginBackgroundTaskWithExpirationHandler:^ {

        //Clean up code. Tell the system that we are done.
        [application endBackgroundTask: background_task];
        background_task = UIBackgroundTaskInvalid;
    }];

    //To make the code block asynchronous
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{

        //### background task starts
        NSLog(@"Running in the background\n");
        static NSString *staticString = @"some const value string to referece";
        while (1 == 1)
        {
            NSDictionary *dictionary;
            NSString *string;
            NSDate *staticStart = [NSDate date];
            NSLog(@"start timing");
            int times = 10000000;
            while (times--) {
                static dispatch_once_t onceToken;
                static NSDictionary *dict;
                dispatch_once(&onceToken, ^{
                    dict = @{@"somekey":@"someotherlongvalue", @"someotherkey":@"someotherlongvalue", @"onelastkey":@"onelastvalue"};
                });
                dictionary = dict;
            }
            NSDate *staticEnd = [NSDate date];
            NSLog(@"finished static dict in %f sec", [staticEnd timeIntervalSinceDate:staticStart]);

            times = 10000000;
            while (times--) {
                dictionary = @{@"somekey":@"someotherlongvalue", @"someotherkey":@"someotherlongvalue", @"onelastkey":@"onelastvalue"};
            }

            NSDate *dictEnd = [NSDate date];
            NSLog(@"finished dict create in %f sec", [dictEnd timeIntervalSinceDate:staticEnd]);

            times = 10000000;
            while (times--) {
                static dispatch_once_t stringOnceToken;
                static NSString *dispatchString;
                dispatch_once(&stringOnceToken, ^{
                    dispatchString = @"someotherlongvalue";
                });
                string = dispatchString;
            }
            NSDate *staticStringEnd = [NSDate date];
            NSLog(@"finished static string in %f sec", [staticStringEnd timeIntervalSinceDate:dictEnd]);
            times = 10000000;
            while (times--) {
                string = @"someotherlongvalue";
            }
            NSDate *stringEnd = [NSDate date];
            NSLog(@"finished string create in %f sec", [stringEnd timeIntervalSinceDate:staticStringEnd]);
            times = 10000000;
            while (times--) {
                string = staticString;
            }
            NSDate *refEnd = [NSDate date];
            NSLog(@"finished string reference in %f sec", [refEnd timeIntervalSinceDate:stringEnd]);
        }
        //#### background task ends

        //Clean up code. Tell the system that we are done.
        [application endBackgroundTask: background_task];
        background_task = UIBackgroundTaskInvalid; 
    });
}
else
{
    NSLog(@"Multitasking Not Supported");
}

      

+3


source to share


1 answer


You have a lot of auto-released objects that never get a chance to be released. Add the autoresource pool to your outer loop:



while (1 == 1) {
    @autoreleasepool {
        // original contents of your loop
    }
}

      

+2


source







All Articles