Re: More than 2, but less than 3 GiB per process memory?
Hello Hendrik!
You wrote:
> [using more than 2 GiB memory for one process on 32bit systems]
> Actually, some kludgery might help here.
>[...]
> Near the start of your program, allocate a *huge* array on the stack, like
>
> char * hugepointer;
> int main(...)
> {
> char huge[1000000000];
> hugepointer = huge;
> restofprogram(...);
> }
That did sound interesting, unfortunately, the following program immediately
segfaults on my machine (with "just" 580 MB allocated via the stack; the
limit where it no longer segfaults is somewhere above 8 MB and below 9 MB):
#include <stdio.h>
char *hugepointer;
struct test {
int t1;
int t2;
int t3;
int t4;
int t5;
int t6;
};
int main() {
struct test *test_p;
int i;
char huge[580000000]; /* 580 MB... (I have 512 MB physical RAM).
8000000 works */
hugepointer = huge;
for (i = 42; i < 90000000; i += 3000000) {
printf("Size: %d sizeof: %d total: %d MiB.\n",
i, sizeof(struct test),
i*sizeof(struct test)/(1024*1024) );
test_p = malloc(sizeof(struct test) * i);
if (!test_p) {
printf("Woopsi\n");
exit(1);
}
free(test_p);
}
}
/* compile me with: gcc memcheck-stack.c -o memcheck-stack */
Reply to: