malloc() over 4Gb

Brooks Davis brooks at one-eyed-alien.net
Mon Jan 26 09:52:40 PST 2004


On Sun, Jan 25, 2004 at 01:37:47PM +0000, ml at fruitbat.demon.co.uk wrote:
> 
> Hi. Could someone clarify whether or not it's possible to malloc()
> and mmap() chunks of memory > 4Gb in size using FreeBSD/AMD64 and
> that FreeBSD/AMD64 isn't susceptible to the 4Gb process boundary that
> 32-bit OSs are restricted by?

It works fine (just remember to set your malloc options to aj before
mallocing that much memory, it takes a loooong time if you done :-):

[9:52am] brooks at brimstone (~): uname -a
FreeBSD brimstone 5.2-CURRENT FreeBSD 5.2-CURRENT #0: Tue Jan  6 13:18:20 PST 2004     brooks at brimstone:/usr/obj/usr/p4/xname/sys/GENERIC  amd64
[9:52am] brooks at brimstone (~): ./a
a.out*    aeroauth* 
[9:52am] brooks at brimstone (~): cat foo.c
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#define GB      (1024*1024*1024)

int
main (int argc, char **argv)
{
        void *foo;

        printf("Trying to malloc %zd bytes\n", (size_t)7*GB);
        foo = malloc((size_t)7*GB);
        if (foo != NULL)
                printf("Success\n");
        else
                printf("failure\n");
}
[9:52am] brooks at brimstone (~): gcc -o foo foo.c
[9:52am] brooks at brimstone (~): ./foo 
Trying to malloc 7516192768 bytes
Success
[9:52am] brooks at brimstone (~): 

-- Brooks

-- 
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-amd64/attachments/20040126/b8eb661e/attachment.bin


More information about the freebsd-amd64 mailing list