├── .gitignore ├── DispatchMemoryLeakDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── DispatchMemoryLeakDemo ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── ViewController.swift └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/xcode,objective-c,swift,osx 3 | 4 | ### Xcode ### 5 | # Xcode 6 | # 7 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 8 | 9 | ## Build generated 10 | build/ 11 | DerivedData 12 | 13 | ## Various settings 14 | *.pbxuser 15 | !default.pbxuser 16 | *.mode1v3 17 | !default.mode1v3 18 | *.mode2v3 19 | !default.mode2v3 20 | *.perspectivev3 21 | !default.perspectivev3 22 | xcuserdata 23 | 24 | ## Other 25 | *.xccheckout 26 | *.moved-aside 27 | *.xcuserstate 28 | 29 | 30 | ### Objective-C ### 31 | # Xcode 32 | # 33 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 34 | 35 | ## Build generated 36 | build/ 37 | DerivedData 38 | 39 | ## Various settings 40 | *.pbxuser 41 | !default.pbxuser 42 | *.mode1v3 43 | !default.mode1v3 44 | *.mode2v3 45 | !default.mode2v3 46 | *.perspectivev3 47 | !default.perspectivev3 48 | xcuserdata 49 | 50 | ## Other 51 | *.xccheckout 52 | *.moved-aside 53 | *.xcuserstate 54 | *.xcscmblueprint 55 | 56 | ## Obj-C/Swift specific 57 | *.hmap 58 | *.ipa 59 | 60 | # CocoaPods 61 | # 62 | # We recommend against adding the Pods directory to your .gitignore. However 63 | # you should judge for yourself, the pros and cons are mentioned at: 64 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 65 | # 66 | # Pods/ 67 | 68 | # Carthage 69 | # 70 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 71 | # Carthage/Checkouts 72 | 73 | Carthage/Build 74 | 75 | # fastlane 76 | # 77 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 78 | # screenshots whenever they are needed. 79 | # For more information about the recommended setup visit: 80 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 81 | 82 | fastlane/report.xml 83 | fastlane/screenshots 84 | 85 | ### Objective-C Patch ### 86 | *.xcscmblueprint 87 | 88 | 89 | ### Swift ### 90 | # Xcode 91 | # 92 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 93 | 94 | ## Build generated 95 | build/ 96 | DerivedData 97 | 98 | ## Various settings 99 | *.pbxuser 100 | !default.pbxuser 101 | *.mode1v3 102 | !default.mode1v3 103 | *.mode2v3 104 | !default.mode2v3 105 | *.perspectivev3 106 | !default.perspectivev3 107 | xcuserdata 108 | 109 | ## Other 110 | *.xccheckout 111 | *.moved-aside 112 | *.xcuserstate 113 | *.xcscmblueprint 114 | 115 | ## Obj-C/Swift specific 116 | *.hmap 117 | *.ipa 118 | 119 | # Swift Package Manager 120 | # 121 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 122 | # Packages/ 123 | .build/ 124 | 125 | # CocoaPods 126 | # 127 | # We recommend against adding the Pods directory to your .gitignore. However 128 | # you should judge for yourself, the pros and cons are mentioned at: 129 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 130 | # 131 | # Pods/ 132 | 133 | # Carthage 134 | # 135 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 136 | # Carthage/Checkouts 137 | 138 | Carthage/Build 139 | 140 | # fastlane 141 | # 142 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 143 | # screenshots whenever they are needed. 144 | # For more information about the recommended setup visit: 145 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 146 | 147 | fastlane/report.xml 148 | fastlane/screenshots 149 | 150 | 151 | ### OSX ### 152 | .DS_Store 153 | .AppleDouble 154 | .LSOverride 155 | 156 | # Icon must end with two \r 157 | Icon 158 | 159 | 160 | # Thumbnails 161 | ._* 162 | 163 | # Files that might appear in the root of a volume 164 | .DocumentRevisions-V100 165 | .fseventsd 166 | .Spotlight-V100 167 | .TemporaryItems 168 | .Trashes 169 | .VolumeIcon.icns 170 | 171 | # Directories potentially created on remote AFP share 172 | .AppleDB 173 | .AppleDesktop 174 | Network Trash Folder 175 | Temporary Items 176 | .apdisk 177 | -------------------------------------------------------------------------------- /DispatchMemoryLeakDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4B06E5901C1FBCB30074A037 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B06E58F1C1FBCB30074A037 /* AppDelegate.swift */; }; 11 | 4B06E5921C1FBCB30074A037 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B06E5911C1FBCB30074A037 /* ViewController.swift */; }; 12 | 4B06E5951C1FBCB30074A037 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4B06E5931C1FBCB30074A037 /* Main.storyboard */; }; 13 | 4B06E5971C1FBCB30074A037 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4B06E5961C1FBCB30074A037 /* Assets.xcassets */; }; 14 | 4B06E59A1C1FBCB30074A037 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4B06E5981C1FBCB30074A037 /* LaunchScreen.storyboard */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 4B06E58C1C1FBCB30074A037 /* DispatchMemoryLeakDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DispatchMemoryLeakDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | 4B06E58F1C1FBCB30074A037 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 20 | 4B06E5911C1FBCB30074A037 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 21 | 4B06E5941C1FBCB30074A037 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 22 | 4B06E5961C1FBCB30074A037 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 23 | 4B06E5991C1FBCB30074A037 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 24 | 4B06E59B1C1FBCB30074A037 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 25 | /* End PBXFileReference section */ 26 | 27 | /* Begin PBXFrameworksBuildPhase section */ 28 | 4B06E5891C1FBCB30074A037 /* Frameworks */ = { 29 | isa = PBXFrameworksBuildPhase; 30 | buildActionMask = 2147483647; 31 | files = ( 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | 4B06E5831C1FBCB30074A037 = { 39 | isa = PBXGroup; 40 | children = ( 41 | 4B06E58E1C1FBCB30074A037 /* DispatchMemoryLeakDemo */, 42 | 4B06E58D1C1FBCB30074A037 /* Products */, 43 | ); 44 | sourceTree = ""; 45 | }; 46 | 4B06E58D1C1FBCB30074A037 /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | 4B06E58C1C1FBCB30074A037 /* DispatchMemoryLeakDemo.app */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | 4B06E58E1C1FBCB30074A037 /* DispatchMemoryLeakDemo */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | 4B06E58F1C1FBCB30074A037 /* AppDelegate.swift */, 58 | 4B06E5911C1FBCB30074A037 /* ViewController.swift */, 59 | 4B06E5931C1FBCB30074A037 /* Main.storyboard */, 60 | 4B06E5961C1FBCB30074A037 /* Assets.xcassets */, 61 | 4B06E5981C1FBCB30074A037 /* LaunchScreen.storyboard */, 62 | 4B06E59B1C1FBCB30074A037 /* Info.plist */, 63 | ); 64 | path = DispatchMemoryLeakDemo; 65 | sourceTree = ""; 66 | }; 67 | /* End PBXGroup section */ 68 | 69 | /* Begin PBXNativeTarget section */ 70 | 4B06E58B1C1FBCB30074A037 /* DispatchMemoryLeakDemo */ = { 71 | isa = PBXNativeTarget; 72 | buildConfigurationList = 4B06E59E1C1FBCB30074A037 /* Build configuration list for PBXNativeTarget "DispatchMemoryLeakDemo" */; 73 | buildPhases = ( 74 | 4B06E5881C1FBCB30074A037 /* Sources */, 75 | 4B06E5891C1FBCB30074A037 /* Frameworks */, 76 | 4B06E58A1C1FBCB30074A037 /* Resources */, 77 | ); 78 | buildRules = ( 79 | ); 80 | dependencies = ( 81 | ); 82 | name = DispatchMemoryLeakDemo; 83 | productName = DispatchMemoryLeakDemo; 84 | productReference = 4B06E58C1C1FBCB30074A037 /* DispatchMemoryLeakDemo.app */; 85 | productType = "com.apple.product-type.application"; 86 | }; 87 | /* End PBXNativeTarget section */ 88 | 89 | /* Begin PBXProject section */ 90 | 4B06E5841C1FBCB30074A037 /* Project object */ = { 91 | isa = PBXProject; 92 | attributes = { 93 | LastSwiftUpdateCheck = 0720; 94 | LastUpgradeCheck = 0720; 95 | ORGANIZATIONNAME = "OneV's Den"; 96 | TargetAttributes = { 97 | 4B06E58B1C1FBCB30074A037 = { 98 | CreatedOnToolsVersion = 7.2; 99 | }; 100 | }; 101 | }; 102 | buildConfigurationList = 4B06E5871C1FBCB30074A037 /* Build configuration list for PBXProject "DispatchMemoryLeakDemo" */; 103 | compatibilityVersion = "Xcode 3.2"; 104 | developmentRegion = English; 105 | hasScannedForEncodings = 0; 106 | knownRegions = ( 107 | en, 108 | Base, 109 | ); 110 | mainGroup = 4B06E5831C1FBCB30074A037; 111 | productRefGroup = 4B06E58D1C1FBCB30074A037 /* Products */; 112 | projectDirPath = ""; 113 | projectRoot = ""; 114 | targets = ( 115 | 4B06E58B1C1FBCB30074A037 /* DispatchMemoryLeakDemo */, 116 | ); 117 | }; 118 | /* End PBXProject section */ 119 | 120 | /* Begin PBXResourcesBuildPhase section */ 121 | 4B06E58A1C1FBCB30074A037 /* Resources */ = { 122 | isa = PBXResourcesBuildPhase; 123 | buildActionMask = 2147483647; 124 | files = ( 125 | 4B06E59A1C1FBCB30074A037 /* LaunchScreen.storyboard in Resources */, 126 | 4B06E5971C1FBCB30074A037 /* Assets.xcassets in Resources */, 127 | 4B06E5951C1FBCB30074A037 /* Main.storyboard in Resources */, 128 | ); 129 | runOnlyForDeploymentPostprocessing = 0; 130 | }; 131 | /* End PBXResourcesBuildPhase section */ 132 | 133 | /* Begin PBXSourcesBuildPhase section */ 134 | 4B06E5881C1FBCB30074A037 /* Sources */ = { 135 | isa = PBXSourcesBuildPhase; 136 | buildActionMask = 2147483647; 137 | files = ( 138 | 4B06E5921C1FBCB30074A037 /* ViewController.swift in Sources */, 139 | 4B06E5901C1FBCB30074A037 /* AppDelegate.swift in Sources */, 140 | ); 141 | runOnlyForDeploymentPostprocessing = 0; 142 | }; 143 | /* End PBXSourcesBuildPhase section */ 144 | 145 | /* Begin PBXVariantGroup section */ 146 | 4B06E5931C1FBCB30074A037 /* Main.storyboard */ = { 147 | isa = PBXVariantGroup; 148 | children = ( 149 | 4B06E5941C1FBCB30074A037 /* Base */, 150 | ); 151 | name = Main.storyboard; 152 | sourceTree = ""; 153 | }; 154 | 4B06E5981C1FBCB30074A037 /* LaunchScreen.storyboard */ = { 155 | isa = PBXVariantGroup; 156 | children = ( 157 | 4B06E5991C1FBCB30074A037 /* Base */, 158 | ); 159 | name = LaunchScreen.storyboard; 160 | sourceTree = ""; 161 | }; 162 | /* End PBXVariantGroup section */ 163 | 164 | /* Begin XCBuildConfiguration section */ 165 | 4B06E59C1C1FBCB30074A037 /* Debug */ = { 166 | isa = XCBuildConfiguration; 167 | buildSettings = { 168 | ALWAYS_SEARCH_USER_PATHS = NO; 169 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 170 | CLANG_CXX_LIBRARY = "libc++"; 171 | CLANG_ENABLE_MODULES = YES; 172 | CLANG_ENABLE_OBJC_ARC = YES; 173 | CLANG_WARN_BOOL_CONVERSION = YES; 174 | CLANG_WARN_CONSTANT_CONVERSION = YES; 175 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 176 | CLANG_WARN_EMPTY_BODY = YES; 177 | CLANG_WARN_ENUM_CONVERSION = YES; 178 | CLANG_WARN_INT_CONVERSION = YES; 179 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 180 | CLANG_WARN_UNREACHABLE_CODE = YES; 181 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 182 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 183 | COPY_PHASE_STRIP = NO; 184 | DEBUG_INFORMATION_FORMAT = dwarf; 185 | ENABLE_STRICT_OBJC_MSGSEND = YES; 186 | ENABLE_TESTABILITY = YES; 187 | GCC_C_LANGUAGE_STANDARD = gnu99; 188 | GCC_DYNAMIC_NO_PIC = NO; 189 | GCC_NO_COMMON_BLOCKS = YES; 190 | GCC_OPTIMIZATION_LEVEL = 0; 191 | GCC_PREPROCESSOR_DEFINITIONS = ( 192 | "DEBUG=1", 193 | "$(inherited)", 194 | ); 195 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 196 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 197 | GCC_WARN_UNDECLARED_SELECTOR = YES; 198 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 199 | GCC_WARN_UNUSED_FUNCTION = YES; 200 | GCC_WARN_UNUSED_VARIABLE = YES; 201 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 202 | MTL_ENABLE_DEBUG_INFO = YES; 203 | ONLY_ACTIVE_ARCH = YES; 204 | SDKROOT = iphoneos; 205 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 206 | }; 207 | name = Debug; 208 | }; 209 | 4B06E59D1C1FBCB30074A037 /* Release */ = { 210 | isa = XCBuildConfiguration; 211 | buildSettings = { 212 | ALWAYS_SEARCH_USER_PATHS = NO; 213 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 214 | CLANG_CXX_LIBRARY = "libc++"; 215 | CLANG_ENABLE_MODULES = YES; 216 | CLANG_ENABLE_OBJC_ARC = YES; 217 | CLANG_WARN_BOOL_CONVERSION = YES; 218 | CLANG_WARN_CONSTANT_CONVERSION = YES; 219 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 220 | CLANG_WARN_EMPTY_BODY = YES; 221 | CLANG_WARN_ENUM_CONVERSION = YES; 222 | CLANG_WARN_INT_CONVERSION = YES; 223 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 224 | CLANG_WARN_UNREACHABLE_CODE = YES; 225 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 226 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 227 | COPY_PHASE_STRIP = NO; 228 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 229 | ENABLE_NS_ASSERTIONS = NO; 230 | ENABLE_STRICT_OBJC_MSGSEND = YES; 231 | GCC_C_LANGUAGE_STANDARD = gnu99; 232 | GCC_NO_COMMON_BLOCKS = YES; 233 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 234 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 235 | GCC_WARN_UNDECLARED_SELECTOR = YES; 236 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 237 | GCC_WARN_UNUSED_FUNCTION = YES; 238 | GCC_WARN_UNUSED_VARIABLE = YES; 239 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 240 | MTL_ENABLE_DEBUG_INFO = NO; 241 | SDKROOT = iphoneos; 242 | VALIDATE_PRODUCT = YES; 243 | }; 244 | name = Release; 245 | }; 246 | 4B06E59F1C1FBCB30074A037 /* Debug */ = { 247 | isa = XCBuildConfiguration; 248 | buildSettings = { 249 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 250 | INFOPLIST_FILE = DispatchMemoryLeakDemo/Info.plist; 251 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 252 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 253 | PRODUCT_BUNDLE_IDENTIFIER = com.onevcat.DispatchMemoryLeakDemo; 254 | PRODUCT_NAME = "$(TARGET_NAME)"; 255 | }; 256 | name = Debug; 257 | }; 258 | 4B06E5A01C1FBCB30074A037 /* Release */ = { 259 | isa = XCBuildConfiguration; 260 | buildSettings = { 261 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 262 | INFOPLIST_FILE = DispatchMemoryLeakDemo/Info.plist; 263 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 264 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 265 | PRODUCT_BUNDLE_IDENTIFIER = com.onevcat.DispatchMemoryLeakDemo; 266 | PRODUCT_NAME = "$(TARGET_NAME)"; 267 | }; 268 | name = Release; 269 | }; 270 | /* End XCBuildConfiguration section */ 271 | 272 | /* Begin XCConfigurationList section */ 273 | 4B06E5871C1FBCB30074A037 /* Build configuration list for PBXProject "DispatchMemoryLeakDemo" */ = { 274 | isa = XCConfigurationList; 275 | buildConfigurations = ( 276 | 4B06E59C1C1FBCB30074A037 /* Debug */, 277 | 4B06E59D1C1FBCB30074A037 /* Release */, 278 | ); 279 | defaultConfigurationIsVisible = 0; 280 | defaultConfigurationName = Release; 281 | }; 282 | 4B06E59E1C1FBCB30074A037 /* Build configuration list for PBXNativeTarget "DispatchMemoryLeakDemo" */ = { 283 | isa = XCConfigurationList; 284 | buildConfigurations = ( 285 | 4B06E59F1C1FBCB30074A037 /* Debug */, 286 | 4B06E5A01C1FBCB30074A037 /* Release */, 287 | ); 288 | defaultConfigurationIsVisible = 0; 289 | }; 290 | /* End XCConfigurationList section */ 291 | }; 292 | rootObject = 4B06E5841C1FBCB30074A037 /* Project object */; 293 | } 294 | -------------------------------------------------------------------------------- /DispatchMemoryLeakDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DispatchMemoryLeakDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // DispatchMemoryLeakDemo 4 | // 5 | // Created by WANG WEI on 2015/12/15. 6 | // Copyright © 2015年 OneV's Den. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 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 | func applicationDidBecomeActive(application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /DispatchMemoryLeakDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /DispatchMemoryLeakDemo/Base.lproj/LaunchScreen.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 | -------------------------------------------------------------------------------- /DispatchMemoryLeakDemo/Base.lproj/Main.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 | -------------------------------------------------------------------------------- /DispatchMemoryLeakDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /DispatchMemoryLeakDemo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // DispatchMemoryLeakDemo 4 | // 5 | // Created by WANG WEI on 2015/12/15. 6 | // Copyright © 2015年 OneV's Den. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | private let testQueue: dispatch_queue_t = dispatch_queue_create("test_queue", DISPATCH_QUEUE_SERIAL) 14 | private var timer: NSTimer! 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | // Do any additional setup after loading the view, typically from a nib. 19 | method() 20 | } 21 | 22 | func method() { 23 | dispatch_async(testQueue) { () -> Void in 24 | dispatch_async(dispatch_get_main_queue(), { () -> Void in 25 | self.method() 26 | }) 27 | } 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DispatchMemoryLeakDemo 2 | 3 | ### [UPDATED] It seems to be a problem of Xcode debug session instead. If you turn off the "Queue Debugging" option in scheme settings, everything goes fine. See [this](https://github.com/onevcat/DispatchMemoryLeakDemo/issues/2) for more. 4 | 5 | A demo that reproduce memory leak in iOS 9.2. You can find the report here [radar://23894846](http://openradar.appspot.com/radar?id=5013034456055808). 6 | --------------------------------------------------------------------------------