Updated Branches:
  refs/heads/master 82cf293dc -> 9e5f8c59f

[CB-4567] fix issue: "Benchmarks" ->"AutoBench" crashed on iOS

The problem seems to be that a lot of autoreleased objects fill up the
memory waiting to be released. So a solution is to add autorelease pool
scope to collect autoreleased objects and release them sooner.

FYI:http://stackoverflow.com/questions/13396560/cant-allocate-region-mal
loc-error-when-running-millions-of-iterations-of-loop


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/9e5f8c59
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/9e5f8c59
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/9e5f8c59

Branch: refs/heads/master
Commit: 9e5f8c59f8f240bd10896380c1c7448fb73cb103
Parents: 82cf293
Author: lmnbeyond <[email protected]>
Authored: Thu Aug 15 10:30:11 2013 +0800
Committer: Max Woghiren <[email protected]>
Committed: Tue Aug 27 11:15:45 2013 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/CDVCommandQueue.m | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e5f8c59/CordovaLib/Classes/CDVCommandQueue.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandQueue.m 
b/CordovaLib/Classes/CDVCommandQueue.m
index 710e463..6af31c8 100644
--- a/CordovaLib/Classes/CDVCommandQueue.m
+++ b/CordovaLib/Classes/CDVCommandQueue.m
@@ -102,19 +102,21 @@
 
             // Iterate over and execute all of the commands.
             for (NSArray* jsonEntry in commandBatch) {
-                CDVInvokedUrlCommand* command = [CDVInvokedUrlCommand 
commandFromJson:jsonEntry];
-                CDV_EXEC_LOG(@"Exec(%@): Calling %@.%@", command.callbackId, 
command.className, command.methodName);
+                @autoreleasepool {
+                    CDVInvokedUrlCommand* command = [CDVInvokedUrlCommand 
commandFromJson:jsonEntry];
+                    CDV_EXEC_LOG(@"Exec(%@): Calling %@.%@", 
command.callbackId, command.className, command.methodName);
 
-                if (![self execute:command]) {
+                    if (![self execute:command]) {
 #ifdef DEBUG
-                        NSString* commandJson = [jsonEntry JSONString];
-                        static NSUInteger maxLogLength = 1024;
-                        NSString* commandString = ([commandJson length] > 
maxLogLength) ?
-                            [NSString stringWithFormat:@"%@[...]", 
[commandJson substringToIndex:maxLogLength]] :
-                            commandJson;
+                            NSString* commandJson = [jsonEntry JSONString];
+                            static NSUInteger maxLogLength = 1024;
+                            NSString* commandString = ([commandJson length] > 
maxLogLength) ?
+                                [NSString stringWithFormat:@"%@[...]", 
[commandJson substringToIndex:maxLogLength]] :
+                                commandJson;
 
-                        DLog(@"FAILED pluginJSON = %@", commandString);
+                            DLog(@"FAILED pluginJSON = %@", commandString);
 #endif
+                    }
                 }
             }
         }

Reply via email to