This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
can't handle 1 Gb
- To: gcc-bugs at gcc dot gnu dot org
- Subject: can't handle 1 Gb
- From: Jos van den Oever <Jos dot vandenOever at fenk dot wag-ur dot nl>
- Date: Thu, 03 Aug 2000 12:50:48 +0200
- Organization: Laboratory of Physical Chemistry and Colloid Science
- Reply-To: Jos dot vandenOever at fenk dot wag-ur dot nl
Hi,
I've attached a program that verbosely allocates memory in steps of 1 Mb and finished when the system refuses to allocate more. I wrote it to find out what the largest process is I can run on a machine. As long as the total available memory is less than 1Gb it works fine. The program stops, cleans up and finishes.
When I compile and run attached program with gcc-2.95.2 under SuSE 6.0 kernel 2.0.38 or with gcc-2.91.66 under Red Hat 6.1 kernel 2.2.15 on machines that have more than 1Gb either swap or real memory, the program gives a segmentation fault just over 1Gb of memory allocated. I've run another program that does heavy equation solving and this can use at least 1.3 Gb which in top is assigned under `lib'. So I figure that refusing to allocate more than 1Gb under some circumstances is a bug.
Best regards, Jos
I used no optimisation.
Here's the output of gdb with -g3
....
....
999000000
1000000000
1001000000
Program received signal SIGSEGV, Segmentation fault.
chunk_alloc (ar_ptr=0x400ca1a0, nb=1000008) at malloc.c:2801
malloc.c:2801: No such file or directory.
Current language: auto; currently c
#include <stdlib.h>
#include <iostream.h>
typedef char * ptr;
int main() {
ptr *z;
z = new ptr[1000];
ptr *zend = z+1000;
ptr *i = z;
while (i < zend) {
*i=NULL;
i++;
}
int size = 1000000;
i = z;
*i = (char *)malloc(size);
while (*i) {
ptr x = *i;
ptr end = *i+size;
while (x<end) {
*x = 0;
x++;
}
cout << (i-z)*size << endl;
i++;
*i = (char *)malloc(size);
}
while (i != z) {
i--;
free(*i);
}
delete [] z;
cout << "finished" << endl;
return 0;
}