[Beowulf] memory allocation on x86_64 returning huge addresses

Greg Lindahl lindahl at pathscale.com
Mon Feb 7 10:41:08 PST 2005


> The problem is that malloc returns an address that is way beyond
> 8billion which is not what I had expected.

This e-vile hack makes it produce something lower in memory. What it does
is turns off glibc's malloc algorithm's feature that has it mmap() large
malloc()s. Stuff into a .c, link the .o into your application.

-- greg

#include <stdio.h>
#include <malloc.h>

static void mem_init_hook(void);
static void *mem_malloc_hook(size_t, const void *);
static void *(*glibc_malloc)(size_t, const void *);
void (*__malloc_initialize_hook)(void) = mem_init_hook;

static void mem_init_hook(void)
{
  mallopt (M_MMAP_MAX, 0);
}



More information about the Beowulf mailing list