delorie.com/archives/browse.cgi | search |
X-Spam-Check-By: | sourceware.org |
Message-ID: | <45783C5D.FEF36B0F@dessent.net> |
Date: | Thu, 07 Dec 2006 08:07:57 -0800 |
From: | Brian Dessent <brian AT dessent DOT net> |
X-Mailer: | Mozilla 4.79 [en] (Windows NT 5.0; U) |
MIME-Version: | 1.0 |
To: | cygwin AT cygwin DOT com |
Subject: | Re: matrix size limitation in cygwin? |
References: | <45783A40 DOT 3080706 AT gmail DOT com> |
X-IsSubscribed: | yes |
Reply-To: | cygwin AT cygwin DOT com |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
"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/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |