On FreeBSD, we have MADV_NOCORE instead of MADV_DONTDUMP. I think we should refactor our code / usage of MADV_DONTDUMP such that there's a single API to be used, which then appropriately picks the right define (or no-op if not defined at all).
I'm not sure what there is for macOS.