
On Thu, Jul 05, 2018 at 08:13:33PM -0400, Viktor Dukhovni wrote:
On Thu, Jul 05, 2018 at 09:32:31AM -0400, Ben Gamari wrote:
We use a much different memory allocation strategy on FreeBSD which (AFAIK) does not allow one to reserve address space without also committing.
Here's a demo of mapping in a 1TB heap on FreeBSD 11.1, on a machine with "just" 64GB of RAM and 160GB swap. I would expect anon memory mappings to behave similarly on older systems.
$ cat foo.c #include
#include #include #include int main(int argc, char **argv) { size_t heaplen = 1ULL << 40; /* 1TB */ unsigned char *heap;
heap = mmap(NULL, heaplen, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); heap[0] = 'A'; heap[heaplen-1] = 'z'; printf ("%p(%zd) %c %c\n", heap, heaplen, heap[0], heap[heaplen-1]); sleep(2); return 0; }
I also get essentially the same results with posix_memalign(3):
#include