title: 1073.75 MB of file backed memory dirtied over 186 seconds (5770.75 KB per second average), exceeding limit of 12.43 KB per second over 86400 seconds
body: <p>iOS crash</p>
  
  <p>Look the crash stack, is it the icloud backup get something error? I don't know what is this error.</p>
  
  <p>Help, thanks.</p>
  
  <pre><code>1073.75 MB of file backed memory dirtied over 186 seconds (5770.75 KB per second average), exceeding limit of 12.43 KB per second over 86400 seconds
  </code></pre>
  
  <pre><code>Command:          HelloTalk_Binary
  Path:             
  Identifier:       
  Version:          3.6.4 (6)
  Beta Identifier:  5D4C1274-7310-4015-9227-B2190563BAE3
  PID:              623
  
  Event:            disk writes
  Action taken:     none
  Writes:           1073.75 MB of file backed memory dirtied over 186 seconds (5770.75 KB per second average), exceeding limit of 12.43 KB per second over 86400 seconds
  Writes limit:     1073.74 MB
  Limit duration:   86400s
  Writes caused:    1073.75 MB
  Writes duration:  186s
  Duration:         186.07s
  Duration Sampled: 45.98s
  Steps:            60 ( (10.49 MB/step))
  
  Hardware model:   iPhone10,3
  Active cpus:      6
  
  
  Heaviest stack for the target process:
    60  ??? (libsystem_pthread.dylib + 48008) [0x18271eb88]
    60  ??? (libdispatch.dylib + 275516) [0x1826b643c]
    60  ??? (libdispatch.dylib + 237864) [0x1826ad128]
    60  ??? (libdispatch.dylib + 235280) [0x1826ac710]
    60  ??? (libdispatch.dylib + 377220) [0x1826cf184]
    60  ??? (libdispatch.dylib + 374288) [0x1826ce610]
    57  ??? (HelloTalk_Binary + 23667476) [0x105792314]
    23  ??? (HelloTalk_Binary + 23665404) [0x105791afc]
    23  ??? (HelloTalk_Binary + 32163208) [0x105fac588]
    23  ??? (&lt;7F66DDA9-9EB4-3CA9-94BF-2E87E9B8B20C&gt; + 47812) [0x108cffac4]
    23  ??? (&lt;7F66DDA9-9EB4-3CA9-94BF-2E87E9B8B20C&gt; + 48280) [0x108cffc98]
    23  ??? (libsystem_c.dylib + 245252) [0x182631e04]
    20  ??? (libsystem_c.dylib + 244268) [0x182631a2c]
    20  ??? (libsystem_c.dylib + 5588) [0x1825f75d4]
    20  ??? (libsystem_kernel.dylib + 154316) [0x1827faacc]
  
  
  Powerstats for:   [623]
  Bundle ID:        
  Adam ID:          0
  Is first party:   No
  App version:      3.6.4
  Build version:    6
  Is Beta:          No
  Share with Devs:  Yes
  UUID:             8A9B6AAB-F4F1-3ADA-9CDF-0C0D23A46AF1
  Path:             
  Architecture:     arm64
  Footprint:        217.66 MB -&gt; 171.48 MB (-46.17 MB) (max 362.86 MB )
  Pageins:          399 pages
  Start time:       2019-11-28 08:58:06 +0800
  End time:         2019-11-28 08:58:52 +0800
  Num samples:      60 (100%)
  CPU Time:         13.931s
  Primary state:    59 samples Frontmost App, Non-Suppressed, Kernel mode, Effective Thread QoS User Initiated, Requested Thread QoS User Initiated, Override Thread QoS Unspecified
  User Activity:    0 samples Idle, 60 samples Active
  Power Source:     60 samples on Battery, 0 samples on AC
    60  ??? (libsystem_pthread.dylib + 48008) [0x18271eb88]
      60  ??? (libdispatch.dylib + 275516) [0x1826b643c]
        60  ??? (libdispatch.dylib + 237864) [0x1826ad128]
          60  ??? (libdispatch.dylib + 235280) [0x1826ac710]
            60  ??? (libdispatch.dylib + 377220) [0x1826cf184]
              60  ??? (libdispatch.dylib + 374288) [0x1826ce610]
                57  __31-[HTBackupToIcloudModel backup]_block_invoke (HTBackupToIcloudModel.m:358 in HelloTalk_Binary + 23667476) [0x105792314]
                  23  -[HTBackupToIcloudModel createBackupFile] (HTBackupToIcloudModel.m:271 in HelloTalk_Binary + 23665404) [0x105791afc]
                    23  -[ZipWriteStream writeData:] (ZipWriteStream.m:53 in HelloTalk_Binary + 32163208) [0x105fac588]
                      23  zipWriteInFileInZip (zip.c:1464 in SSZipArchive + 47812) [0x108cffac4]
                        23  zip64FlushWriteBuffer (zip.c:1381 in SSZipArchive + 48280) [0x108cffc98]
                          23  ??? (libsystem_c.dylib + 245252) [0x182631e04]
                            20  ??? (libsystem_c.dylib + 244268) [0x182631a2c]
                              20  ??? (libsystem_c.dylib + 5588) [0x1825f75d4]
                                20  ??? (libsystem_kernel.dylib + 154316) [0x1827faacc]
                            3   ??? (libsystem_c.dylib + 244316) [0x182631a5c]
                              3   ??? (libsystem_c.dylib + 235260) [0x18262f6fc]
                                3   ??? (libsystem_c.dylib + 5588) [0x1825f75d4]
                                  3   ??? (libsystem_kernel.dylib + 154316) [0x1827faacc]
                  20  -[HTBackupToIcloudModel createBackupFile] (HTBackupToIcloudModel.m:272 in HelloTalk_Binary + 23665416) [0x105791b08]
                    20  -[ZipWriteStream finishedWriting] (ZipWriteStream.m:61 in HelloTalk_Binary + 32163424) [0x105fac660]
                      18  zipCloseFileInZipRaw64 (zip.c:1589 in SSZipArchive + 48540) [0x108cffd9c]
                        18  zip64FlushWriteBuffer (zip.c:1381 in SSZipArchive + 48280) [0x108cffc98]
                          18  ??? (libsystem_c.dylib + 245252) [0x182631e04]
                            18  ??? (libsystem_c.dylib + 244268) [0x182631a2c]
                              18  ??? (libsystem_c.dylib + 5588) [0x1825f75d4]
                                18  ??? (libsystem_kernel.dylib + 154316) [0x1827faacc]
                      2   zipCloseFileInZipRaw64 (zip.c:1718 in SSZipArchive + 49524) [0x108d00174]
                        2   ??? (libsystem_c.dylib + 5144) [0x1825f7418]
                          2   ??? (libsystem_c.dylib + 243516) [0x18263173c]
                            2   ??? (libsystem_c.dylib + 235260) [0x18262f6fc]
                              2   ??? (libsystem_c.dylib + 5588) [0x1825f75d4]
                                2   ??? (libsystem_kernel.dylib + 154316) [0x1827faacc]
                  13  -[HTBackupToIcloudModel createBackupFile] (HTBackupToIcloudModel.m:252 in HelloTalk_Binary + 23664864) [0x1057918e0]
                    13  -[ZipWriteStream writeData:] (ZipWriteStream.m:53 in HelloTalk_Binary + 32163208) [0x105fac588]
                      13  zipWriteInFileInZip (zip.c:1464 in SSZipArchive + 47812) [0x108cffac4]
                        13  zip64FlushWriteBuffer (zip.c:1381 in SSZipArchive + 48280) [0x108cffc98]
                          13  ??? (libsystem_c.dylib + 245252) [0x182631e04]
                            13  ??? (libsystem_c.dylib + 244268) [0x182631a2c]
                              13  ??? (libsystem_c.dylib + 5588) [0x1825f75d4]
                                13  ??? (libsystem_kernel.dylib + 154316) [0x1827faacc]
                  1   -[HTBackupToIcloudModel createBackupFile] (HTBackupToIcloudModel.m:253 in HelloTalk_Binary + 23664876) [0x1057918ec]
                    1   -[ZipWriteStream finishedWriting] (ZipWriteStream.m:61 in HelloTalk_Binary + 32163424) [0x105fac660]
                      1   zipCloseFileInZipRaw64 (zip.c:1589 in SSZipArchive + 48540) [0x108cffd9c]
                        1   zip64FlushWriteBuffer (zip.c:1381 in SSZipArchive + 48280) [0x108cffc98]
                          1   ??? (libsystem_c.dylib + 245252) [0x182631e04]
                            1   ??? (libsystem_c.dylib + 244268) [0x182631a2c]
                              1   ??? (libsystem_c.dylib + 5588) [0x1825f75d4]
                                1   ??? (libsystem_kernel.dylib + 154316) [0x1827faacc]
                2   __25-[HTCache synchronizeNow]_block_invoke (HTCache.m:555 in HelloTalk_Binary + 28087512) [0x105bc94d8]
                  2   ??? (Foundation + 424364) [0x182d1a9ac]
                    2   ??? (Foundation + 1163316) [0x182dcf034]
                      2   ??? (Foundation + 297596) [0x182cfba7c]
                        2   ??? (Foundation + 1164516) [0x182dcf4e4]
                          2   ??? (libsystem_kernel.dylib + 162716) [0x1827fcb9c]
                            1   &lt;Effective Thread QoS User Interactive&gt;
                1   __53-[SensorsAnalyticsSDK track:withProperties:withType:]_block_invoke (SensorsAnalyticsSDK.m:1668 in SensorsAnalyticsSDK + 194464) [0x108d477a0]
                  1   -[SensorsAnalyticsSDK enqueueWithType:andEvent:] (SensorsAnalyticsSDK.m:1404 in SensorsAnalyticsSDK + 187712) [0x108d45d40]
                    1   -[MessageQueueBySqlite addObejct:withType:] (MessageQueueBySqlite.m:115 in SensorsAnalyticsSDK + 31508) [0x108d1fb14]
                      1   ??? (libsqlite3.dylib + 269148) [0x18465ab5c]
                        1   ??? (libsqlite3.dylib + 313648) [0x184665930]
                          1   ??? (libsqlite3.dylib + 440088) [0x184684718]
                            1   ??? (libsqlite3.dylib + 437700) [0x184683dc4]
                              1   ??? (libsqlite3.dylib + 427668) [0x184681694]
                                1   ??? (libsqlite3.dylib + 483304) [0x18468efe8]
                                  1   ??? (libsystem_kernel.dylib + 157916) [0x1827fb8dc]
  
  
  </code></pre>
  
  <pre><code>- (BOOL)createBackupFile {
      @autoreleasepool {
          NSFileManager *fileManager = NSFileManager.new;
  
          // 创建缓存路径
          NSString *tmpICloudPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"iCloud"];
          if ([fileManager fileExistsAtPath:tmpICloudPath isDirectory:NULL]) {
              [[NSFileManager defaultManager] removeItemAtPath:tmpICloudPath error:NULL];
          }
          [fileManager createDirectoryAtPath:tmpICloudPath withIntermediateDirectories:YES attributes:NULL error:NULL];
  
          NSString *zipFilePath = [tmpICloudPath stringByAppendingPathComponent:@"Backup.zip"];
          if ([fileManager fileExistsAtPath:zipFilePath]) {
              [fileManager removeItemAtPath:zipFilePath error:NULL];
          }
  
          ZipFile *zipFile= [[ZipFile alloc] initWithFileName:zipFilePath mode:ZipFileModeCreate];
  
          // 开始压缩
          NSInteger totalFileCounts = 0;
  
          // 压缩数据库
          NSString *dbBackupPath = nil;
          NSArray *dbSubpaths = nil;
          @autoreleasepool {
              dbBackupPath = [HTPath localBackupPathWithUserId:[[HTCache sharedCache] stringForKey:HT_UserId]];
              dbSubpaths = [fileManager subpathsAtPath:dbBackupPath];
              totalFileCounts += dbSubpaths.count;
          }
  
          // 压缩语音
          NSString *audioPath = nil;
          NSArray *audioSubpaths = nil;
          @autoreleasepool {
              audioPath = [HTPath localAudioPathWithUserId:[[HTCache sharedCache] stringForKey:HT_UserId]];
              audioSubpaths = [fileManager subpathsAtPath:audioPath];
              totalFileCounts += audioSubpaths.count;
          }
  
          // 压缩图片
          NSString *imagesPath = nil;
          NSMutableArray *imageSubpaths = nil;
          @autoreleasepool {
              imagesPath = [HTPath localImagePathWithUserId:[[HTCache sharedCache] stringForKey:HT_UserId]];
              NSArray *tempImagesSubPath = [fileManager subpathsAtPath:imagesPath];
              imageSubpaths = [NSMutableArray array];
              for (NSString *path in tempImagesSubPath) {
                  if ([path hasSuffix:@"_thum.jpg"]) {
                      [imageSubpaths addObject:path];
                  }
              }
  
              totalFileCounts += imageSubpaths.count;
          }
  
          // 压缩视频缩略图，不压缩视频文件
          NSString *videosPath = nil;
          NSMutableArray *videoSubpaths = nil;
          @autoreleasepool {
              videosPath = [HTPath localVideoPathWithUserId:[[HTCache sharedCache] stringForKey:HT_UserId]];
              NSArray *tempVideoSubpaths = [fileManager subpathsAtPath:videosPath];
              videoSubpaths = [NSMutableArray array];
              for (NSString *path in tempVideoSubpaths) {
                  if([path hasSuffix:@"_thum.jpg"]) {
                      [videoSubpaths addObject:path];
                  }
              }
  
              totalFileCounts += videoSubpaths.count;
          }
  
          float onePercent = 1 / (float)totalFileCounts;
          float tempTotalPercent = self.conpressProgress / 100.0f;
  
          NSLog(@"iCloud total files: %@", @(totalFileCounts).stringValue);
  
          BOOL isDir = YES;
          for(NSString *path in dbSubpaths){
              @autoreleasepool {
                  NSString *fullPath = [dbBackupPath stringByAppendingPathComponent:path];
                  if([fileManager fileExistsAtPath:fullPath isDirectory:&amp;isDir] &amp;&amp; !isDir){
                      ZipWriteStream *stream= [zipFile writeFileInZipWithName:[NSString stringWithFormat:@"Backup/Backup/%@", path] compressionLevel:ZipCompressionLevelFastest];
                      NSData *data = [[NSData alloc] initWithContentsOfFile:fullPath options:NSDataReadingUncached error:NULL];
                      [stream writeData:data];
                      [stream finishedWriting];
                  }
              }
  
              tempTotalPercent += onePercent;
              int conpressProgress = tempTotalPercent * 100;
              if (conpressProgress != self.conpressProgress) {
                  self.conpressProgress = conpressProgress;
              }
          }
  
  
          for(NSString *path in audioSubpaths){
              @autoreleasepool {
                  NSString *fullPath = [audioPath stringByAppendingPathComponent:path];
                  if([fileManager fileExistsAtPath:fullPath isDirectory:&amp;isDir] &amp;&amp; !isDir){
                      ZipWriteStream *stream= [zipFile writeFileInZipWithName:[NSString stringWithFormat:@"Backup/audios/%@", path] compressionLevel:ZipCompressionLevelNone];
                      NSData *data = [[NSData alloc] initWithContentsOfFile:fullPath options:NSDataReadingUncached error:NULL];
                      [stream writeData:data];
                      [stream finishedWriting];
                  }
              }
  
              tempTotalPercent += onePercent;
              int conpressProgress = tempTotalPercent * 100;
              if (conpressProgress != self.conpressProgress) {
                  self.conpressProgress = conpressProgress;
              }
          }
  
  
          for(NSString *path in imageSubpaths){
              @autoreleasepool {
                  NSString *fullPath = [imagesPath stringByAppendingPathComponent:path];
                  if([fileManager fileExistsAtPath:fullPath isDirectory:&amp;isDir] &amp;&amp; !isDir){
                      ZipWriteStream *stream= [zipFile writeFileInZipWithName:[NSString stringWithFormat:@"Backup/images/%@", path] compressionLevel:ZipCompressionLevelNone];
                      NSData *data = [[NSData alloc] initWithContentsOfFile:fullPath options:NSDataReadingUncached error:NULL];
                      [stream writeData:data];
                      [stream finishedWriting];
                  }
              }
  
              tempTotalPercent += onePercent;
              int conpressProgress = tempTotalPercent * 100;
              if (conpressProgress != self.conpressProgress) {
                  self.conpressProgress = conpressProgress;
              }
          }
  
  
          for(NSString *path in videoSubpaths){
              @autoreleasepool {
                  NSString *fullPath = [videosPath stringByAppendingPathComponent:path];
                  if([fileManager fileExistsAtPath:fullPath isDirectory:&amp;isDir] &amp;&amp; !isDir){
                      ZipWriteStream *stream= [zipFile writeFileInZipWithName:[NSString stringWithFormat:@"Backup/videos/%@", path] compressionLevel:ZipCompressionLevelFastest];
                      NSData *data = [[NSData alloc] initWithContentsOfFile:fullPath options:NSDataReadingUncached error:NULL];
                      [stream writeData:data];
                      [stream finishedWriting];
                  }
              }
  
              tempTotalPercent += onePercent;
              int conpressProgress = tempTotalPercent * 100;
              if (conpressProgress != self.conpressProgress) {
                  self.conpressProgress = conpressProgress;
              }
          }
  
          [zipFile close];
          [zipFile release];
  
          NSLog(@"conpress end");
  
          NSDictionary *attributes = [fileManager attributesOfItemAtPath:zipFilePath error:NULL];
          self.backupSize = [attributes doubleForKey:NSFileSize] / (1024.0f * 1024.0f);
  
          return YES;
      }
  
  }
  </code></pre>