RE: memory problem

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

 



If you're allocating this array on the stack, then you're just running
into stack size problems.  The maximum stack size is limited by the OS,
and if your stack frame ends up larger than that, your program will
segfault like this.  Basically, you just need to increase your maximum
stack size, or allocate the array dynamically, which would probably be
preferable.

Run 'ulimit -s' to see what your stack size limit is set to (probably
something like 8 MB).  You can also use that command to change it
temporarily.

Thanks,
Lyle


-----Original Message-----
From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On
Behalf Of xuejun gu
Sent: Thursday, January 13, 2005 10:31 AM
To: gcc-help@xxxxxxxxxxx
Subject: memory problem

HI,

The machine I used have 6GB physical memory. However, when I run the c++

program I found the biggest array I can assign like

double A[10000][100]

I complied as:

$ gcc test1.cpp -o test1
$ ./test1'

When I increased the array size to double A[10000][120], it gave the 
message:
'Segmentation fault'


Is there any way to solve the problem?

Thanks!


here is the detail information of my machine:

1) cat /proc/meminfo

        total:    used:    free:  shared: buffers:  cached:
Mem:  6349705216 1669341184 4680364032        0 161710080 1048535040
Swap: 6547218432        0 6547218432
MemTotal:      6200884 kB
MemFree:       4570668 kB
MemShared:           0 kB
Buffers:        157920 kB
Cached:        1023960 kB
SwapCached:          0 kB
Active:         970660 kB
Inactive:       425152 kB
HighTotal:     5373376 kB
HighFree:      4126628 kB
LowTotal:       827508 kB
LowFree:        444040 kB
SwapTotal:     6393768 kB
SwapFree:      6393768 kB

2) cat /etc/redhat-release

Red Hat Linux release 9 (Shrike)

3) gcc  -v

Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

4) cat /proc/mtrr
reg00: base=0x100000000 (4096MB), size=2048MB: write-back, count=1
reg01: base=0x180000000 (6144MB), size=1024MB: write-back, count=1
reg02: base=0x00000000 (   0MB), size=2048MB: write-back, count=1
reg03: base=0x80000000 (2048MB), size=1024MB: write-back, count=1
reg04: base=0xbff80000 (3071MB), size= 512KB: uncachable, count=1
reg05: base=0xbff80000 (3071MB), size= 512KB: uncachable, count=1
reg06: base=0xc8000000 (3200MB), size= 128MB: write-combining,
count=1
reg07: base=0xe0000000 (3584MB), size= 256MB: write-combining,
count=1

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!

http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux