├── MemoryTest.xcodeproj └── project.pbxproj ├── MemoryTest ├── AppDelegate.h ├── AppDelegate.m ├── Default-568h@2x.png ├── Default.png ├── Default@2x.png ├── MemoryTest-Info.plist ├── MemoryTest-Prefix.pch ├── ViewController.h ├── ViewController.m ├── en.lproj │ ├── InfoPlist.strings │ └── MainStoryboard.storyboard └── main.m └── README.md /MemoryTest.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 55A231FC16488541001C3E62 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 55A231FB16488541001C3E62 /* README.md */; }; 11 | 55F58DBA164838D4008566AE /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55F58DB9164838D4008566AE /* UIKit.framework */; }; 12 | 55F58DBC164838D4008566AE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55F58DBB164838D4008566AE /* Foundation.framework */; }; 13 | 55F58DBE164838D4008566AE /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55F58DBD164838D4008566AE /* CoreGraphics.framework */; }; 14 | 55F58DC4164838D4008566AE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 55F58DC2164838D4008566AE /* InfoPlist.strings */; }; 15 | 55F58DC6164838D4008566AE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 55F58DC5164838D4008566AE /* main.m */; }; 16 | 55F58DCA164838D4008566AE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 55F58DC9164838D4008566AE /* AppDelegate.m */; }; 17 | 55F58DCC164838D4008566AE /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 55F58DCB164838D4008566AE /* Default.png */; }; 18 | 55F58DCE164838D4008566AE /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 55F58DCD164838D4008566AE /* Default@2x.png */; }; 19 | 55F58DD0164838D5008566AE /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 55F58DCF164838D5008566AE /* Default-568h@2x.png */; }; 20 | 55F58DD3164838D5008566AE /* MainStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 55F58DD1164838D5008566AE /* MainStoryboard.storyboard */; }; 21 | 55F58DD9164838D5008566AE /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 55F58DD8164838D5008566AE /* ViewController.m */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXFileReference section */ 25 | 55A231FB16488541001C3E62 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = SOURCE_ROOT; }; 26 | 55F58DB5164838D4008566AE /* MemoryTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MemoryTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | 55F58DB9164838D4008566AE /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 28 | 55F58DBB164838D4008566AE /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 29 | 55F58DBD164838D4008566AE /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 30 | 55F58DC1164838D4008566AE /* MemoryTest-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "MemoryTest-Info.plist"; sourceTree = ""; }; 31 | 55F58DC3164838D4008566AE /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 32 | 55F58DC5164838D4008566AE /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 33 | 55F58DC7164838D4008566AE /* MemoryTest-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MemoryTest-Prefix.pch"; sourceTree = ""; }; 34 | 55F58DC8164838D4008566AE /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 35 | 55F58DC9164838D4008566AE /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 36 | 55F58DCB164838D4008566AE /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 37 | 55F58DCD164838D4008566AE /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 38 | 55F58DCF164838D5008566AE /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 39 | 55F58DD2164838D5008566AE /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard.storyboard; sourceTree = ""; }; 40 | 55F58DD7164838D5008566AE /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 41 | 55F58DD8164838D5008566AE /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 42 | /* End PBXFileReference section */ 43 | 44 | /* Begin PBXFrameworksBuildPhase section */ 45 | 55F58DB2164838D4008566AE /* Frameworks */ = { 46 | isa = PBXFrameworksBuildPhase; 47 | buildActionMask = 2147483647; 48 | files = ( 49 | 55F58DBA164838D4008566AE /* UIKit.framework in Frameworks */, 50 | 55F58DBC164838D4008566AE /* Foundation.framework in Frameworks */, 51 | 55F58DBE164838D4008566AE /* CoreGraphics.framework in Frameworks */, 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 55F58DAA164838D4008566AE = { 59 | isa = PBXGroup; 60 | children = ( 61 | 55F58DBF164838D4008566AE /* MemoryTest */, 62 | 55F58DB8164838D4008566AE /* Frameworks */, 63 | 55F58DB6164838D4008566AE /* Products */, 64 | ); 65 | sourceTree = ""; 66 | }; 67 | 55F58DB6164838D4008566AE /* Products */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | 55F58DB5164838D4008566AE /* MemoryTest.app */, 71 | ); 72 | name = Products; 73 | sourceTree = ""; 74 | }; 75 | 55F58DB8164838D4008566AE /* Frameworks */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 55F58DB9164838D4008566AE /* UIKit.framework */, 79 | 55F58DBB164838D4008566AE /* Foundation.framework */, 80 | 55F58DBD164838D4008566AE /* CoreGraphics.framework */, 81 | ); 82 | name = Frameworks; 83 | sourceTree = ""; 84 | }; 85 | 55F58DBF164838D4008566AE /* MemoryTest */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | 55F58DC8164838D4008566AE /* AppDelegate.h */, 89 | 55F58DC9164838D4008566AE /* AppDelegate.m */, 90 | 55F58DD1164838D5008566AE /* MainStoryboard.storyboard */, 91 | 55F58DD7164838D5008566AE /* ViewController.h */, 92 | 55F58DD8164838D5008566AE /* ViewController.m */, 93 | 55F58DC0164838D4008566AE /* Supporting Files */, 94 | ); 95 | path = MemoryTest; 96 | sourceTree = ""; 97 | }; 98 | 55F58DC0164838D4008566AE /* Supporting Files */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 55A231FB16488541001C3E62 /* README.md */, 102 | 55F58DC1164838D4008566AE /* MemoryTest-Info.plist */, 103 | 55F58DC2164838D4008566AE /* InfoPlist.strings */, 104 | 55F58DC5164838D4008566AE /* main.m */, 105 | 55F58DC7164838D4008566AE /* MemoryTest-Prefix.pch */, 106 | 55F58DCB164838D4008566AE /* Default.png */, 107 | 55F58DCD164838D4008566AE /* Default@2x.png */, 108 | 55F58DCF164838D5008566AE /* Default-568h@2x.png */, 109 | ); 110 | name = "Supporting Files"; 111 | sourceTree = ""; 112 | }; 113 | /* End PBXGroup section */ 114 | 115 | /* Begin PBXNativeTarget section */ 116 | 55F58DB4164838D4008566AE /* MemoryTest */ = { 117 | isa = PBXNativeTarget; 118 | buildConfigurationList = 55F58DDC164838D5008566AE /* Build configuration list for PBXNativeTarget "MemoryTest" */; 119 | buildPhases = ( 120 | 55F58DB1164838D4008566AE /* Sources */, 121 | 55F58DB2164838D4008566AE /* Frameworks */, 122 | 55F58DB3164838D4008566AE /* Resources */, 123 | ); 124 | buildRules = ( 125 | ); 126 | dependencies = ( 127 | ); 128 | name = MemoryTest; 129 | productName = MemoryTest; 130 | productReference = 55F58DB5164838D4008566AE /* MemoryTest.app */; 131 | productType = "com.apple.product-type.application"; 132 | }; 133 | /* End PBXNativeTarget section */ 134 | 135 | /* Begin PBXProject section */ 136 | 55F58DAC164838D4008566AE /* Project object */ = { 137 | isa = PBXProject; 138 | attributes = { 139 | LastUpgradeCheck = 0450; 140 | ORGANIZATIONNAME = "Jan Ilavsky"; 141 | }; 142 | buildConfigurationList = 55F58DAF164838D4008566AE /* Build configuration list for PBXProject "MemoryTest" */; 143 | compatibilityVersion = "Xcode 3.2"; 144 | developmentRegion = English; 145 | hasScannedForEncodings = 0; 146 | knownRegions = ( 147 | en, 148 | ); 149 | mainGroup = 55F58DAA164838D4008566AE; 150 | productRefGroup = 55F58DB6164838D4008566AE /* Products */; 151 | projectDirPath = ""; 152 | projectRoot = ""; 153 | targets = ( 154 | 55F58DB4164838D4008566AE /* MemoryTest */, 155 | ); 156 | }; 157 | /* End PBXProject section */ 158 | 159 | /* Begin PBXResourcesBuildPhase section */ 160 | 55F58DB3164838D4008566AE /* Resources */ = { 161 | isa = PBXResourcesBuildPhase; 162 | buildActionMask = 2147483647; 163 | files = ( 164 | 55F58DC4164838D4008566AE /* InfoPlist.strings in Resources */, 165 | 55F58DCC164838D4008566AE /* Default.png in Resources */, 166 | 55F58DCE164838D4008566AE /* Default@2x.png in Resources */, 167 | 55F58DD0164838D5008566AE /* Default-568h@2x.png in Resources */, 168 | 55F58DD3164838D5008566AE /* MainStoryboard.storyboard in Resources */, 169 | 55A231FC16488541001C3E62 /* README.md in Resources */, 170 | ); 171 | runOnlyForDeploymentPostprocessing = 0; 172 | }; 173 | /* End PBXResourcesBuildPhase section */ 174 | 175 | /* Begin PBXSourcesBuildPhase section */ 176 | 55F58DB1164838D4008566AE /* Sources */ = { 177 | isa = PBXSourcesBuildPhase; 178 | buildActionMask = 2147483647; 179 | files = ( 180 | 55F58DC6164838D4008566AE /* main.m in Sources */, 181 | 55F58DCA164838D4008566AE /* AppDelegate.m in Sources */, 182 | 55F58DD9164838D5008566AE /* ViewController.m in Sources */, 183 | ); 184 | runOnlyForDeploymentPostprocessing = 0; 185 | }; 186 | /* End PBXSourcesBuildPhase section */ 187 | 188 | /* Begin PBXVariantGroup section */ 189 | 55F58DC2164838D4008566AE /* InfoPlist.strings */ = { 190 | isa = PBXVariantGroup; 191 | children = ( 192 | 55F58DC3164838D4008566AE /* en */, 193 | ); 194 | name = InfoPlist.strings; 195 | sourceTree = ""; 196 | }; 197 | 55F58DD1164838D5008566AE /* MainStoryboard.storyboard */ = { 198 | isa = PBXVariantGroup; 199 | children = ( 200 | 55F58DD2164838D5008566AE /* en */, 201 | ); 202 | name = MainStoryboard.storyboard; 203 | sourceTree = ""; 204 | }; 205 | /* End PBXVariantGroup section */ 206 | 207 | /* Begin XCBuildConfiguration section */ 208 | 55F58DDA164838D5008566AE /* Debug */ = { 209 | isa = XCBuildConfiguration; 210 | buildSettings = { 211 | ALWAYS_SEARCH_USER_PATHS = NO; 212 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 213 | CLANG_CXX_LIBRARY = "libc++"; 214 | CLANG_ENABLE_OBJC_ARC = YES; 215 | CLANG_WARN_EMPTY_BODY = YES; 216 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 217 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 218 | COPY_PHASE_STRIP = NO; 219 | GCC_C_LANGUAGE_STANDARD = gnu99; 220 | GCC_DYNAMIC_NO_PIC = NO; 221 | GCC_OPTIMIZATION_LEVEL = 0; 222 | GCC_PREPROCESSOR_DEFINITIONS = ( 223 | "DEBUG=1", 224 | "$(inherited)", 225 | ); 226 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 227 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 228 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 229 | GCC_WARN_UNUSED_VARIABLE = YES; 230 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 231 | ONLY_ACTIVE_ARCH = YES; 232 | SDKROOT = iphoneos; 233 | TARGETED_DEVICE_FAMILY = "1,2"; 234 | }; 235 | name = Debug; 236 | }; 237 | 55F58DDB164838D5008566AE /* Release */ = { 238 | isa = XCBuildConfiguration; 239 | buildSettings = { 240 | ALWAYS_SEARCH_USER_PATHS = NO; 241 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 242 | CLANG_CXX_LIBRARY = "libc++"; 243 | CLANG_ENABLE_OBJC_ARC = YES; 244 | CLANG_WARN_EMPTY_BODY = YES; 245 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 246 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 247 | COPY_PHASE_STRIP = YES; 248 | GCC_C_LANGUAGE_STANDARD = gnu99; 249 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 250 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 251 | GCC_WARN_UNUSED_VARIABLE = YES; 252 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 253 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 254 | SDKROOT = iphoneos; 255 | TARGETED_DEVICE_FAMILY = "1,2"; 256 | VALIDATE_PRODUCT = YES; 257 | }; 258 | name = Release; 259 | }; 260 | 55F58DDD164838D5008566AE /* Debug */ = { 261 | isa = XCBuildConfiguration; 262 | buildSettings = { 263 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 264 | GCC_PREFIX_HEADER = "MemoryTest/MemoryTest-Prefix.pch"; 265 | INFOPLIST_FILE = "MemoryTest/MemoryTest-Info.plist"; 266 | PRODUCT_NAME = "$(TARGET_NAME)"; 267 | WRAPPER_EXTENSION = app; 268 | }; 269 | name = Debug; 270 | }; 271 | 55F58DDE164838D5008566AE /* Release */ = { 272 | isa = XCBuildConfiguration; 273 | buildSettings = { 274 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 275 | GCC_PREFIX_HEADER = "MemoryTest/MemoryTest-Prefix.pch"; 276 | INFOPLIST_FILE = "MemoryTest/MemoryTest-Info.plist"; 277 | PRODUCT_NAME = "$(TARGET_NAME)"; 278 | WRAPPER_EXTENSION = app; 279 | }; 280 | name = Release; 281 | }; 282 | /* End XCBuildConfiguration section */ 283 | 284 | /* Begin XCConfigurationList section */ 285 | 55F58DAF164838D4008566AE /* Build configuration list for PBXProject "MemoryTest" */ = { 286 | isa = XCConfigurationList; 287 | buildConfigurations = ( 288 | 55F58DDA164838D5008566AE /* Debug */, 289 | 55F58DDB164838D5008566AE /* Release */, 290 | ); 291 | defaultConfigurationIsVisible = 0; 292 | defaultConfigurationName = Release; 293 | }; 294 | 55F58DDC164838D5008566AE /* Build configuration list for PBXNativeTarget "MemoryTest" */ = { 295 | isa = XCConfigurationList; 296 | buildConfigurations = ( 297 | 55F58DDD164838D5008566AE /* Debug */, 298 | 55F58DDE164838D5008566AE /* Release */, 299 | ); 300 | defaultConfigurationIsVisible = 0; 301 | defaultConfigurationName = Release; 302 | }; 303 | /* End XCConfigurationList section */ 304 | }; 305 | rootObject = 55F58DAC164838D4008566AE /* Project object */; 306 | } 307 | -------------------------------------------------------------------------------- /MemoryTest/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MemoryTest 4 | // 5 | // Created by Jan Ilavsky on 11/5/12. 6 | // Copyright (c) 2012 Jan Ilavsky. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /MemoryTest/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // MemoryTest 4 | // 5 | // Created by Jan Ilavsky on 11/5/12. 6 | // Copyright (c) 2012 Jan Ilavsky. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application 20 | { 21 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application 26 | { 27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application 32 | { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | - (void)applicationDidBecomeActive:(UIApplication *)application 37 | { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application 42 | { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /MemoryTest/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Split82/iOSMemoryBudgetTest/ae2bcd5542d9f7a549924195727cbac2dd3e5830/MemoryTest/Default-568h@2x.png -------------------------------------------------------------------------------- /MemoryTest/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Split82/iOSMemoryBudgetTest/ae2bcd5542d9f7a549924195727cbac2dd3e5830/MemoryTest/Default.png -------------------------------------------------------------------------------- /MemoryTest/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Split82/iOSMemoryBudgetTest/ae2bcd5542d9f7a549924195727cbac2dd3e5830/MemoryTest/Default@2x.png -------------------------------------------------------------------------------- /MemoryTest/MemoryTest-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | Hyperbolic-Magnetism.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIMainStoryboardFile 28 | MainStoryboard 29 | UIMainStoryboardFile~ipad 30 | MainStoryboard 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /MemoryTest/MemoryTest-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'MemoryTest' target in the 'MemoryTest' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_5_0 8 | #warning "This project uses features only available in iOS SDK 5.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /MemoryTest/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // MemoryTest 4 | // 5 | // Created by Jan Ilavsky on 11/5/12. 6 | // Copyright (c) 2012 Jan Ilavsky. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /MemoryTest/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // MemoryTest 4 | // 5 | // Created by Jan Ilavsky on 11/5/12. 6 | // Copyright (c) 2012 Jan Ilavsky. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import 11 | #import 12 | 13 | #define CRASH_MEMORY_FILE_NAME @"CrashMemory.dat" 14 | #define MEMORY_WARNINGS_FILE_NAME @"MemoryWarnings.dat" 15 | 16 | 17 | @interface ViewController () { 18 | 19 | NSTimer *timer; 20 | 21 | int allocatedMB; 22 | Byte *p[10000]; 23 | uint64_t physicalMemorySize; 24 | uint64_t userMemorySize; 25 | 26 | NSMutableArray *infoLabels; 27 | NSMutableArray *memoryWarnings; 28 | 29 | BOOL initialLayoutFinished; 30 | BOOL firstMemoryWarningReceived; 31 | } 32 | 33 | @property (weak, nonatomic) IBOutlet UIView *progressBarBG; 34 | @property (weak, nonatomic) IBOutlet UIView *alocatedMemoryBar; 35 | @property (weak, nonatomic) IBOutlet UIView *kernelMemoryBar; 36 | @property (weak, nonatomic) IBOutlet UILabel *userMemoryLabel; 37 | @property (weak, nonatomic) IBOutlet UILabel *totalMemoryLabel; 38 | @property (weak, nonatomic) IBOutlet UIButton *startButton; 39 | 40 | @end 41 | 42 | @implementation ViewController 43 | 44 | #pragma mark - Helpers 45 | 46 | - (void)refreshUI { 47 | 48 | int physicalMemorySizeMB = physicalMemorySize / 1048576; 49 | int userMemorySizeMB = userMemorySize / 1048576; 50 | 51 | self.userMemoryLabel.text = [NSString stringWithFormat:@"%d MB -", userMemorySizeMB]; 52 | self.totalMemoryLabel.text = [NSString stringWithFormat:@"%d MB -", physicalMemorySizeMB]; 53 | 54 | CGRect rect; 55 | 56 | CGFloat userMemoryProgressLength = self.progressBarBG.bounds.size.height * (userMemorySizeMB / (float)physicalMemorySizeMB); 57 | 58 | rect = self.userMemoryLabel.frame; 59 | rect.origin.y = roundf((self.progressBarBG.bounds.size.height - userMemoryProgressLength) - self.userMemoryLabel.bounds.size.height * 0.5f + self.progressBarBG.frame.origin.y - 3); 60 | self.userMemoryLabel.frame = rect; 61 | 62 | rect = self.kernelMemoryBar.frame; 63 | rect.size.height = roundf(self.progressBarBG.bounds.size.height - userMemoryProgressLength); 64 | self.kernelMemoryBar.frame = rect; 65 | 66 | rect = self.alocatedMemoryBar.frame; 67 | rect.size.height = roundf(self.progressBarBG.bounds.size.height * (allocatedMB / (float)physicalMemorySizeMB)); 68 | rect.origin.y = self.progressBarBG.bounds.size.height - rect.size.height; 69 | self.alocatedMemoryBar.frame = rect; 70 | } 71 | 72 | - (void)refreshMemoryInfo { 73 | 74 | // Get memory info 75 | int mib[2]; 76 | size_t length; 77 | mib[0] = CTL_HW; 78 | 79 | mib[1] = HW_MEMSIZE; 80 | length = sizeof(int64_t); 81 | sysctl(mib, 2, &physicalMemorySize, &length, NULL, 0); 82 | 83 | mib[1] = HW_USERMEM; 84 | length = sizeof(int64_t); 85 | sysctl(mib, 2, &userMemorySize, &length, NULL, 0); 86 | } 87 | 88 | - (void)allocateMemory { 89 | 90 | p[allocatedMB] = malloc(1048576); 91 | memset(p[allocatedMB], 0, 1048576); 92 | allocatedMB += 1; 93 | 94 | [self refreshMemoryInfo]; 95 | [self refreshUI]; 96 | 97 | if (firstMemoryWarningReceived) { 98 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 99 | NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; 100 | [NSKeyedArchiver archiveRootObject:@(allocatedMB) toFile:[basePath stringByAppendingPathComponent:CRASH_MEMORY_FILE_NAME]]; 101 | } 102 | } 103 | 104 | - (void)clearAll { 105 | 106 | for (int i = 0; i < allocatedMB; i++) { 107 | free(p[i]); 108 | } 109 | 110 | allocatedMB = 0; 111 | 112 | [infoLabels makeObjectsPerformSelector:@selector(removeFromSuperview)]; 113 | [infoLabels removeAllObjects]; 114 | 115 | [memoryWarnings removeAllObjects]; 116 | } 117 | 118 | - (void)addLabelAtMemoryProgress:(int)memory text:(NSString*)text color:(UIColor*)color { 119 | 120 | CGFloat length = self.progressBarBG.bounds.size.height * (1.0f - memory / (float)(physicalMemorySize / 1048576)); 121 | 122 | CGRect rect; 123 | rect.origin.x = 20; 124 | rect.size.width = self.progressBarBG.frame.origin.x - rect.origin.x - 8; 125 | rect.size.height = 20; 126 | rect.origin.y = roundf(self.progressBarBG.frame.origin.y + length - rect.size.height * 0.5f); 127 | 128 | UILabel *label = [[UILabel alloc] initWithFrame:rect]; 129 | label.textAlignment = NSTextAlignmentRight; 130 | label.text = [NSString stringWithFormat:@"%@ %d MB -", text, memory]; 131 | label.font = self.totalMemoryLabel.font; 132 | label.textColor = color; 133 | 134 | [infoLabels addObject:label]; 135 | [self.view addSubview:label]; 136 | } 137 | 138 | #pragma mark - View lifecycle 139 | 140 | - (void)viewDidLoad 141 | { 142 | [super viewDidLoad]; 143 | 144 | infoLabels = [[NSMutableArray alloc] init]; 145 | memoryWarnings = [[NSMutableArray alloc] init]; 146 | } 147 | 148 | - (void)viewDidLayoutSubviews { 149 | 150 | if (!initialLayoutFinished) { 151 | 152 | [self refreshMemoryInfo]; 153 | [self refreshUI]; 154 | 155 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 156 | NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; 157 | NSInteger crashMemory = [[NSKeyedUnarchiver unarchiveObjectWithFile:[basePath stringByAppendingPathComponent:CRASH_MEMORY_FILE_NAME]] intValue]; 158 | if (crashMemory > 0) { 159 | [self addLabelAtMemoryProgress:crashMemory text:@"Crash" color:[UIColor colorWithRed:0.8 green:0.0 blue:0.0 alpha:1.0]]; 160 | } 161 | 162 | NSArray *lastMemoryWarnings = [NSKeyedUnarchiver unarchiveObjectWithFile:[basePath stringByAppendingPathComponent:MEMORY_WARNINGS_FILE_NAME]]; 163 | if (lastMemoryWarnings) { 164 | 165 | for (NSNumber *number in lastMemoryWarnings) { 166 | 167 | [self addLabelAtMemoryProgress:[number intValue] text:@"Memory Warning" color:[UIColor colorWithWhite:0.6 alpha:1.0]]; 168 | } 169 | } 170 | 171 | initialLayoutFinished = YES; 172 | } 173 | } 174 | 175 | - (void)viewDidUnload { 176 | 177 | [timer invalidate]; 178 | [self clearAll]; 179 | 180 | infoLabels = nil; 181 | memoryWarnings = nil; 182 | 183 | initialLayoutFinished = NO; 184 | 185 | [super viewDidUnload]; 186 | } 187 | 188 | - (void)didReceiveMemoryWarning 189 | { 190 | [super didReceiveMemoryWarning]; 191 | 192 | firstMemoryWarningReceived = YES; 193 | 194 | [self addLabelAtMemoryProgress:allocatedMB text:@"Memory Warning" color:[UIColor colorWithWhite:0.6 alpha:1.0]]; 195 | 196 | [memoryWarnings addObject:@(allocatedMB)]; 197 | 198 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 199 | NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; 200 | [NSKeyedArchiver archiveRootObject:memoryWarnings toFile:[basePath stringByAppendingPathComponent:MEMORY_WARNINGS_FILE_NAME]]; 201 | } 202 | 203 | #pragma mark - Actions 204 | 205 | - (IBAction)startButtonPressed:(id)sender { 206 | 207 | [self clearAll]; 208 | 209 | firstMemoryWarningReceived = NO; 210 | 211 | [timer invalidate]; 212 | timer = [NSTimer scheduledTimerWithTimeInterval:0.02 target:self selector:@selector(allocateMemory) userInfo:nil repeats:YES]; 213 | } 214 | 215 | @end 216 | 217 | -------------------------------------------------------------------------------- /MemoryTest/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /MemoryTest/en.lproj/MainStoryboard.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 40 | 48 | 63 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /MemoryTest/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MemoryTest 4 | // 5 | // Created by Jan Ilavsky on 11/5/12. 6 | // Copyright (c) 2012 Jan Ilavsky. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOS Memory Budget Test 2 | 3 | is an iOS application which tries to allocate as much memory as possible to crash. After that you can run the application again to see how much memory was needed for crash and when all the memory warnings happen. 4 | 5 | ![Alt text](http://cl.ly/image/0J0b441P1d3q/Image%202012.11.06%2012:45:51%20AM.png) --------------------------------------------------------------------------------