-2

Possible Duplicate:
How to get information about free memory and running processes in an App Store approved app? (Yes, there is one!)

How to get available memory in IOS ? I don't know..

I googled, then I know how can i get the physical memory, user memory and used mem, free mem in VM.

But. the memory size is different with which is Settings -> General -> About -> Avaliable.

I want to know "Avaliable" in Settings.

Have a nice day .

Community
  • 1
  • 1
alex
  • 19
  • 1
  • 3
  • I think you mean "available storage" -- http://stackoverflow.com/a/8036586/603256 – JamesHalsall May 18 '12 at 08:03
  • Does the following work for you? http://stackoverflow.com/questions/5012886/knowing-available-ram-on-an-ios-device – Andreas Ley May 18 '12 at 08:04
  • Oh. I see. That's right. "available storage"... but one more question. I got the "available storage" use behind the method, but a little different .. always 200MB or 160MB. why .. ? help me .. – alex May 21 '12 at 05:29

1 Answers1

1

found this on here a few months back cant remember who originally posted. Is this what you are looking for?

- (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;
}