Why process memory starts so high up in virtual space with FreeBSD malloc?

Dan Nelson dnelson at allantgroup.com
Mon Dec 1 15:43:16 PST 2008

In the last episode (Dec 01), Dan Nelson said: 
> Here's what I get with a simple test program on a month-old 7.1-PRE

Gah. silly mailing-list attachment stripper.

#include <stdlib.h>
#include <stdio.h>

int main(void)
  size_t malloced = 0;
  size_t chunksize = 1024*1024;
  void *first = NULL;
  void *last = NULL;
  void *ptr;
  while ((ptr = malloc(chunksize)) != NULL) {
    if (first == NULL)
      first = ptr;
    last = ptr;
    malloced += chunksize;
  printf("Malloced %zu bytes. First: %p, Last: %p\n", malloced, first, last);

	Dan Nelson
	dnelson at allantgroup.com

More information about the freebsd-questions mailing list