This is the mail archive of the cygwin mailing list for the Cygwin 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: matrix size limitation in cygwin?


"Fam. Ivanescu Gruia" wrote:

> I try to make C program in CygWin having declared matrix variables like:
> 
> float lats[1000][1000],lons[1000]
> [1000];
> 
> It compiles, but when I run the executable I got:
> 
> Segmentation fault (core dumped)
> 
> It seems that the 1000 value is too big. If I put 500 it works. However,
> I need to use 1000 and I'm wandering if this limitation in CygWin may be
> adjusted in any ways. Do you have please any idea?

Try a good book on C.  When you allocate local variables in this way
they go on the stack, which is not an infinite resource - typically it
defaults to something on the order of 4MB or so.  You can increase the
default stack size during linking (see the ld manual) but that is really
a bad idea because you are misusing the stack for bulk allocation when
it is meant only for temporary storage.

For large arrays you need to use the heap, which you do by
malloc/calloc/etc.

This is not Cygwin specific at all, this is how C works.  It just
happens that the default stack size on Windows is probably smaller than
whatever other platform you are testing on.  It's very bad to rely on a
specific stack size, again this is not what the stack is meant for.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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