-2

重複の可能性:
App Store 承認済みアプリで空きメモリと実行中のプロセスに関する情報を取得するにはどうすればよいですか? (はい、あります!)

IOS で利用可能なメモリを取得するには? 知らない..

私はググったところ、VMで物理メモリ、ユーザーメモリ、使用済みメモリ、空きメモリを取得する方法がわかりました。

しかし。Settings -> General -> About -> Available でメモリサイズが異なります。

設定の「利用可能」を知りたい。

良い1日を 。

4

1 に答える 1

1

数か月前にここでこれを見つけましたが、最初に誰が投稿したか思い出せません。これはあなたが探しているものですか?

- (uint64_t)freeDiskspace
{
uint64_t totalSpace = 0;
uint64_t totalFreeSpace = 0;

__autoreleasing NSError *error = nil;  
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);  
NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];  

if (dictionary) {  
    NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];  
    NSNumber *freeFileSystemSizeInBytes = [dictionary objectForKey:NSFileSystemFreeSize];
    totalSpace = [fileSystemSizeInBytes unsignedLongLongValue];
    totalFreeSpace = [freeFileSystemSizeInBytes unsignedLongLongValue];
    NSLog(@"Memory Capacity of %llu MiB with %llu MiB Free memory available.", ((totalSpace/1024ll)/1024ll), ((totalFreeSpace/1024ll)/1024ll));
   } else {  
    NSLog(@"Error Obtaining System Memory Info: Domain = %@, Code = %@", [error domain], [error code]);  
}  

return totalFreeSpace;
}
于 2012-05-18T18:46:49.443 に答える