This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Problems with array size limits


You're problem is not due to GCC, but rather is due to the stack size
limit on your OS.  Each OS may have a different limit on how large the
stack can be.  This has a direct effect on how large you can make
statically allocated arrays (e.g., arrays declared as local variables in
functions).  When working with large datasets, it's better to
dynamically allocate the memory for your arrays (using malloc/free in C
or new/delete in C++)so that it gets allocated on the heap.  The only
limitation you have then is the amount of virtual memory available
(physical memory + swap) to your process.

Keep in mind that effective memory management is one of the larger (more
important and easy to screw up) problems when programming in C and C++.
If you don't have much experience in that area, I would recommend
reading up on it first to thoroughly familiarize yourself with the ideas
and techniques involved.

Otherwise, as a temporary work around until you can properly update your
program, you can temporarily adjust the stack size limit for programs on
Linux using the ulimit command.  Just running 'ulimit -s' will show you
what your current setting is.  'ulimit -s <value>' will set it.

Good luck,
Lyle


-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Daniel Silvestre
Sent: Tuesday, January 25, 2005 2:11 PM
To: gcc-help@gcc.gnu.org
Subject: Problems with array size limits

Greetings GCC people,

I'm having problems in runtime with some programs. First of all, I'm a
newbie programmer with little experience, so any help goes !!
Some months ago, using Mandrake 10.0 community and its version of GCC
I've written some C programs to deal with genomic sequences.
Everything worked very well.
But now, using Mandrake 10.1 Official PP with gcc 3.4.1 or even icc
8.1 the programs compile but don run ! And tracing the problem I've
found:

collect2: ld terminated with signal 11 [Segmentation fault]

I've supposed that must be a problem with arrays size. Testing this
hypothesis showed that the size limits of arrays have changed. When I
reduce some arrays the problem vanishes.

How can I tell my gcc to surpass this size limit?
That's it !!!

Cordially,
Daniel Marques



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]