[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: More than 2, but less than 3 GiB per process memory?

On Mon, 26 Sep 2005 11:34:15 -0600
bob@proulx.com (Bob Proulx) wrote:

> Hendrik Boom wrote:
> > > Malte Cornils wrote:
> > > > Does anyone have a clue why 2 GiB is the limit?
> It is not for me.  I can malloc() up to 2.9G.
> > It seems malloc restricts itself to the user space.
> > But if you were te replace malloc (or provide your own
> > allocation and freeing methods, which *miht* be possible
> > in C++) you could do the following.
> Although I am sure the details of malloc() are involved I
> don't think that is squarely the problem here.  I have a
> simple test program which mallocs and reports and I can
> definitely get to 2.9 on a 32-bit system.
>   Out of memory at 2934 M

I get the same message at 3057MB.  Even 

This test has to be bogus, though, because my RAM+swap is
less than 2GiB.

This lets me alloc a 1650MB on a desktop w/ 1GB RAM, 1GB swap,
GNOME 2.10, lots of pages open in Firefox, etc.

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
int main(int argc, char **argv)
    unsigned long mb = atoi(argv[1]) * 1024 * 1024;

    char *p = malloc(mb);
    memset(p, 0xDEAD, (mb/2));

Reply to: