开发者

Show available Physical memory on Device (iphone/ipad)

开发者 https://www.devze.com 2023-02-14 18:06 出处:网络
Anybody knows how to 开发者_开发问答find out how much physical memory is used and available now?

Anybody knows how to 开发者_开发问答find out how much physical memory is used and available now?

I need to show in my iPad application smth like this:

Free memory is 14.1 / 16Gb You application's files takes 1412 Mb

I will store big files in my app and should know about used memory - to delete some files and write new

smth like physical memory managment


It sounds like by "memory" you mean filesystem storage. Something like this should get you what you want:

NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSDictionary *info = [[NSFileManager defaultManager] attributesOfFileSystemForPath:path error:NULL];
NSUInteger totalSpace = [[info objectForKey:NSFileSystemSize] unsignedIntegerValue];
NSUInteger freeSpace = [[info objectForKey:NSFileSystemFreeSize] unsignedIntegerValue];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号