It seems that bin/files purge fails when trying to run on large file uploads. In the example below, F125732 is a 1GB gzipped tarball.
>>> [2] <connect> phabricator_file
<<< [2] <connect> 3,361 us
>>> [3] <query> SELECT `f`.* FROM `file` f WHERE (f.id IN (125732)) ORDER BY `f`.`id` DESC
<<< [3] <query> 632 us
>>> [4] <query> SELECT edge.* FROM `edge` edge WHERE (edge.src IN ('PHID-FILE-jv4mivvrsnubujfig6vj')) AND (edge.type IN ('26')) ORDER BY edge.dateCreated DESC, edge.seq DESC
<<< [4] <query> 648 us
>>> [5] <query> SELECT * FROM `file_transformedfile` WHERE transformedPHID IN ('PHID-FILE-jv4mivvrsnubujfig6vj')
<<< [5] <query> 615 us
>>> [6] <s3>
<<< [6] <s3> 29,027,285 us
>>> [7] <kvcache-get>
>>> [8] <connect> phabricator_cache
<<< [8] <connect> 2,070 us
>>> [9] <query> SELECT * FROM `cache_general` WHERE cacheKeyHash IN ('BnTlrCiB63YN')
<<< [9] <query> 653 us
<<< [7] <kvcache-get> 4,065 us
>>> [10] <kvcache-get>
>>> [11] <query> SELECT * FROM `cache_general` WHERE cacheKeyHash IN ('BnTlrCiB63YN')
<<< [11] <query> 658 us
<<< [10] <kvcache-get> 921 us
mmap() failed: [12] Cannot allocate memory
mmap() failed: [12] Cannot allocate memory
PHP Fatal error: Out of memory (allocated 1740173312) (tried to allocate 1721295440 bytes) in /usr/local/src/phabricator/src/applications/files/engine/PhabricatorFileStorageEngine.php on line 354
Fatal error: Out of memory (allocated 1740173312) (tried to allocate 1721295440 bytes) in /usr/local/src/phabricator/src/applications/files/engine/PhabricatorFileStorageEngine.php on line 354