It seems the Initial Block Download (IBD) on macOS Catalina uses a lot more disk space than expected, and will result in an unsuccesful download even when 480 GB of free disk space is available at the beginning. 

**Expected behavior**

That the Initial Block Download finishes after using _about_ 284 GB of disk space, as indicated by the Welcome window.

![ibd-480-GB-available-at-least-284-GB-required](https://user-images.githubusercontent.com/20860124/71561974-754a2880-2a86-11ea-9887-9b0d19106498.png)

**Actual behavior**

When the download reaches 52% completion, over 284 GB of disk space has already been consumed. If the download is left to run, the machine will run out of disk space and Bitcoin Core will stop/quit before completing the download.

Looking a bit into the Bitcoin directory and what could be causing it, the files prefixed _rev_ in the _blocks_ folder are a lot larger than they are when compared to a previous blockchain downloaded on Linux.

Comparing the rev*.dat files with a previous successful IBD on Linux (below mounted with ext4fuse), the rev files use at most 23M, and the total is 32G:
```
blocks # pwd
/Users/erik/linux-ext4/bitcoin/.bitcoin/blocks

blocks # du -ch rev*.dat | sort -n
6.0M	rev01866.dat
 12M	rev00311.dat
 12M	rev00328.dat
 13M	rev00314.dat
 14M	rev00295.dat
 14M	rev00309.dat
 ...
 21M	rev01206.dat
 21M	rev01291.dat
 23M	rev01036.dat
 32G	total
```

On Mac, the rev files will be significantly larger than 23M. You can see that the files can get as large as 184M, and in this case where 22.8% of the blockchain had been downloaded, we were already using 48G for just the rev files, 107G for the whole data directory.
```
$ tail -n 1 /Users/erik/Library/Application\ Support/Bitcoin/debug.log
2019-12-29T07:30:29Z UpdateTip: new best=0000000000000000025930ce69bc9fcfae882de7231457f09534da493e114c52 height=399555 version=0x00000004 log2_work=84.162383 tx=111703322 date='2016-02-22T08:57:07Z' progress=0.228149 cache=466.9MiB(3406855txo)

$ du -ch /Users/erik/Library/Application\ Support/Bitcoin/blocks/rev*.dat | sort -n
 16M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00003.dat
 17M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00056.dat
 18M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00006.dat
 20M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00000.dat
 21M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00450.dat
 24M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00078.dat
 27M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00002.dat
 ...
171M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00232.dat
172M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00266.dat
172M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00334.dat
174M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00256.dat
175M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00143.dat
175M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00275.dat
177M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00132.dat
177M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00204.dat
178M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00337.dat
184M	/Users/erik/Library/Application Support/Bitcoin/blocks/rev00208.dat
 48G	total

$ du -ch /Users/erik/Library/Application\ Support/Bitcoin
 91M	/Users/erik/Library/Application Support/Bitcoin/blocks/index
105G	/Users/erik/Library/Application Support/Bitcoin/blocks
1.8G	/Users/erik/Library/Application Support/Bitcoin/chainstate
2.0M	/Users/erik/Library/Application Support/Bitcoin/wallets
107G	/Users/erik/Library/Application Support/Bitcoin
107G	total
```

Here you can see the Linux-Mac diff side by side:
![linux-vs-mac](https://user-images.githubusercontent.com/20860124/71562589-f2779c80-2a8a-11ea-9097-6163e36ecf47.png)

**To reproduce**

- Download and install Bitcoin Core 0.19.0.1 on a Mac with a fresh install of macOS Catalina 10.15.2
- Start Bitcoin Core and select the default data directory and leave the prune checkbox unchecked (see picture at the start of the report)
- After downloading ~55% of the blockchain, check the disk space use of the ~/Library/Application Support/Bitcoin folder, it should now already exceed 284 GB
- If you had 480 GB of free space when starting the download, you should not be able to finish the download before running out of disk space

**Possible workaround**

Based on https://bitcoin.stackexchange.com/questions/11104/what-is-the-database-for/11108#11108 it seems the rev*.dat files can be removed to free up disk space. By deleting the earlier ones created I was able to free up enough space continue and complete the IBD on the Mac mini. However, doing so may lead to side effects that I am unaware of.

**System information**

bitcoin-0.19.0.1-osx.dmg downloaded from https://bitcoin.org/en/download 

Machine 1:
- Mac mini (Late 2012)
- 2,5 GHz Dual-Core Intel Core i5
- 16 GB 1600 MHz DDR3
- macOS Catalina 10.15.2 (fresh install on a 500 GB SSD)

Machine 2: 
- MacBook Pro (15-inch, 2018) 
- 2,6 GHz 6-Core Intel Core i7
- 32 GB 2400 MHz DDR4
- macOS Catalina 10.15.2 (upgraded from Mojave)



#include <util/system.h>
#include <chainparamsbase.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/translation.h>
#if (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__))
#include <pthread.h>
#include <pthread_np.h>
#endif
#ifndef WIN32
#ifdef __linux__
#ifdef _POSIX_C_SOURCE
#undef _POSIX_C_SOURCE
#endif
#define _POSIX_C_SOURCE 200112L
#endif 
#include <algorithm>
#include <fcntl.h>
#include <sched.h>
#include <sys/resource.h>
#include <sys/stat.h>
#else
#ifdef _MSC_VER
#pragma warning(disable:4786)
#pragma warning(disable:4804)
#pragma warning(disable:4805)
#pragma warning(disable:4717)
#endif