4

我允许用户从他/她的库中挑选视频。当照片库打开时,如果我要查看设置->常规->使用情况,似乎会在文档和数据中添加大约 1.5Mb。用户选择视频并对其进行压缩后,文档和数据中总共会添加大约 4.5Mb。我的问题是这个数据/内存似乎永远不会释放。这一切都是在完成任何类型的保存之前添加的。所以文件和数据使用量不断增加,我不知道为什么。我很确定一切都被释放了。

- (void)viewDidAppear:(BOOL)animated
 {
//[super viewDidAppear:animated];
      if (IsFirstCall) {

          UIImagePickerController *uploadPick = [[[UIImagePickerController alloc] init] autorelease] ;
          uploadPick.delegate = self;
          uploadPick.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
          uploadPick.mediaTypes = [[[NSArray alloc] initWithObjects:(NSString *) kUTTypeMovie, nil] autorelease];   

         [self presentViewController:uploadPick animated:YES completion:nil];
         //[uploadPick release];
    }
}

任何帮助是极大的赞赏。我认为不可能在实际手机上使用文件管理器工具,它似乎只适用于模拟器。我花了很多时间试图弄清楚为什么会这样。

4

1 回答 1

1

A possibility of what is happening here is actually temporary files being saved. You mention that compressing the video seems to trigger this increase in space.

There's two ways that you could confirm this by one of two methods. By restarting the device you're testing on. Temporary items will get cleared away by the system either when additional space is required, or when the system shuts down.

The other method (and probably more informative) is to investigate the Application through the Xcode organiser. You can do this by selecting the Application on the device and browsing the Applications directory structure. Each application gets 3 directories, /Documents, /Library and /tmp.

For intensive operations, that may require the use of a lot of memory, certain libraries will save completed data out to disk, in order to free up memory. Once the operation is completed it will then pass you back a block of data that either references the data in the temporary file, or has the completed data loaded back into memory. This process is completely transparent to the user and developer, and takes advantage of the large amount of flash memory, rather than relying completely on the comparatively limited RAM.

In the event that it is not a temporary file, but rather something sitting within the Documents folder of the Application (or even the library), it could be useful to download it to your computer and attempt to investigate its contents, as it may give you some clues as to what is happening.

Hope this helps

Edited a point for clarity

于 2013-02-07T22:58:22.867 回答