Recently, I have came across many apps which "Clear Cache" on iPhone. They also specify that you may lose some saved data and temp files.
What I know is that Apple doesn't allows you to access data of other Apps neither directory. So, how they are cleaning cache data? Can anyone put some light on it?
Reference: Magic Phone Cleaner
4 Answers
Answers 1
They simply fill the free space on iPhone temporarily with random data leaving the system with no free space at all.
This forces iOS to clear all temp data, caches and iCloud Photos -if you enabled storage optimization- to clear space. So basically they are tricking the system to force it to clear temp and cached data.
Answers 2
No app can access anything outside of it's sandbox environment. In other words, technically it's impossible to clean cache on an iPhone unless it's jailbroken. Most of these apps doesn't do what they say, they just give an illusion to user. Loading up the memory can force iOS to terminate other apps in the background but, I it's unlikely that it will give any performance boost.
Answers 3
I read the disassembly of the Magic Phone Cleaner app and here what the app do:
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true); NSError *error = nil; NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[path lastObject] error:&error]; if (!error) { // get the free space on the user partition unsigned long long freeSize = [attributes[NSFileSystemFreeSize] unsignedLongLongValue]; // get the path for "cacheWipe.txt" on the app temporary files directory NSString *dummyFilePath = [[NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingString:@"cacheWipe.txt"]] path]; NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:dummyFilePath]; // seek is used to fill the file with 0s [handle seekToFileOffset:freeSize]; // create data and write it to the file above NSData *data = [@"foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo" dataUsingEncoding:NSUnicodeStringEncoding]; [handle writeData:data]; // delete the file from the the app temporary files directory [[NSFileManager defaultManager] removeItemAtPath:dummyFilePath error:&error]; }else{ NSLog(@"Error Obtaining System Memory Info: Domain = %@, Code = %ld", [error domain], [error code]); }
Please note that the iPhone, iPod or iPad have 2 partitions, User Partition and System Partition. The system partition is read only and its mounted to / while the user partition is read write and mounted to /private/var
This code try to get the free space on the user partition and then create a file with the same size as the free space on the user partition, this is what seekToFileOffset do. Then the end of that file will be filled with foofoo... to commit changes to storage.
Answers 4
It doesn't clear data in external apps, it clears external data left by apps. Clearing the cache basically deletes all the temporary files.
0 comments:
Post a Comment