How much space do duplicate files occupy on your iPad? In theory, they don't use additional storage. Thanks to the Apple File System (APFS) design used in iOS and macOS, duplicating a file doesn't really create a copy. Simply create a reference that points to the original file on the disk.
But what about file providers, iCloud and all that? I decided to take a deep dive and find out if you can really make millions of copies of a file without penalty. The results were, to say the least, confusing.
Duplicates are free
APFS has a feature called APFS Cloning. The clearest explanation I've found comes from Mike Bombich, developer of the Mac Carbon Copy Cloner backup application. I will paste it here to read it:
APFS cloning allows the user to instantly create copies of files on the same volume without consuming additional storage space. When cloning a file, the file system does not create copies of the data, but creates a second reference to the file that can be modified independently of the first file.
The two files will share disk storage for portions of the files that remain identical, but changes to any of the files will be written to different parts of the disk. APFS file cloning only works when you make copies of a file on the same volume (for example, duplicate a file or folder in the Finder).
This was written about APFS on Mac, but it should also apply to iOS. For example, if you make 10 copies of a 1 GB file, then it only occupies 1 GB. The other "copies" are just references to that original file. However, if you modify one of those references, it will become a real duplicate file. So far, so simple.
Do file providers work the same way?
But what happens if your applications use file providers? Do they count as separate volumes? Does this mean that iOS will make a real copy when moving files to and from these locations?
First, however, what is a file provider? Check out the Files application. On the left side there is a column that shows Locations:
Those are File Providers. Some provide access to cloud storage (such as Dropbox), but some are local. Third-party applications such as Kymatica AudioShare and Readdle Documents use a File Provider to open their storage in the application to any other application that wishes. So, my question is, are File Provers counted as separate storage volumes or as part of the main volume?
No good data
The problem with investigating this in iOS is that it is difficult to obtain a reliable number for the actual amount of storage used. I decided to take numbers from three sources: iTunes and iMazing on a connected Mac, plus the iPad storage report. I wrote down the numbers, then made seven copies of the same 1.54GB file. The file, a download of drum machine samples, was in the Readdle Documents application, and I moved it to the AudioShare storage area using the Files application.
This is how the three sources reported storage before the copy operation. All sizes in GB and numbers in brackets were calculated by me, using 512 GB as the total unit size:
- iTunes: ( 173.06 used ) 338.94 free
- iPad: 148.3 used (363.7 free)
- iMazing: 241.48 used 270GB free
Not a good start. Those numbers are not close to each other. Even so, they may agree on the difference in storage space in the before / after test.
Before and after
I copied the same file seven times, from the Document file provider to the AudioShare file provider. The copy took a few moments. It seems that it would be impossible to copy almost 10 GB of data in such a short time. Only with this information, I assumed that these copies were actually APFS clones. But what did the numbers say?
- iTunes: ( 173.14 used ), 338.86 free
- iPad: 159.1 used (352.9 free)
- iMazing: 252.3 used 259.7 free
So, the differences in the space used are the following:
- iTunes: 0.08 GB
- iPad: 10.8 GB
- iMazing: 10.82 GB
Here we go! This is much more useful information. Seven copies of that 1.54 GB file total 10.78 GB. Both the iPad's native storage tool and iMazing report this amount of extra space used. But iTunes says no additional storage has been used. That's weird. Maybe we can find more information?
Here we can see the storage measures for Documents and for AudioShare. The documents remain the same, as expected: we are copying of . AudioShare shows an increase of 10.78GB. That is the exact size of those seven copied files. What's going on?
Well, it is possible that iTunes is wrong or correct. If it is correct, the iPad reports are incorrect. There is not much more to say about this, without more information. But how about one more test? Let's copy a file to the folder on my iPad of the iPad itself, and then copy that file several times to another folder. We will completely ignore the file providers for this test, and then compare our results of both tests.
Test 2: copies of simple old files
I deleted the copies we made in the first test, emptied the iPad bin, emptied the AudioShare bin itself and moved the file from try the iPad download folder. (Interestingly, the files I deleted from the AudioShare File Provider did not appear in the Files section Recently Deleted also known as the iPad Trash).
Then I synchronized with iTunes, and press reload on iMazing. The method used to run the test was exactly the same as the previous test, only I first copied the file to another folder in the section On my iPad, and then used the Duplicate command to create a total of seven copies.
This time, I will save you the actual measurements and only present the conclusions, that is, the storage difference before / after used:
- iTunes: 0.74 GB
- iPad: 10.8 GB
- iMazing: 10.79 GB
In summary, these are practically identical to the first set of results. Copies between File Provider silos give the same result as copies of files in the "native" iPad storage area.
APFS is magical
Apple's own APFS specification says that duplicate files on the same volume are clones, not copies. In both tests, the result was the same: iTunes did not report an increase in used storage, while the iPad and iMazing agreed that those files actually took up more space.
case, one conclusion is that iTunes is right, because it agrees with Apple's own APFS description. And if that is the case, moving files in and out of File Providers is the same as moving them in the same folder.
If you know more about how this works, let me know, either in the comments, or via Twitter / microblog / email.