Newsgroups: fj.os.linux,fj.lang.c
Path: galaxy.trc.rwcp.or.jp!coconuts.jaist!wnoc-tyo-news!sinfony-news01!news.kddnet.ad.jp!news.dvlp.kddnet.ad.jp!news.cs.ritsumei.ac.jp!kuis-news!kuee-news!odins-suita!chiba-ns!hagi!is.tsukuba.ac.jp!tai
From: tai@softlab.is.tsukuba.ac.jp (Hideki TAI)
Subject: Re: memory allocation limit of gcc
References: <MASAOKA.97Jan7091956@ss.marine.osakafu-u.ac.jp>
Date: Wed, 8 Jan 1997 08:37:49 GMT
Mime-Version: 1.0
Nntp-Posting-Host: 130.158.80.84
X-Newsreader: slrn (0.9.1.1jp2 BETA UNIX)
Content-Type: text/plain; charset=ISO-2022-JP
Organization: Institute of Information Sciences & Electronics, University of Tsukuba, Japan
Sender: news@is.tsukuba.ac.jp (News Manager)
Message-ID: <1997Jan8.083749.15497@is.tsukuba.ac.jp>
Lines: 50
Xref: galaxy.trc.rwcp.or.jp fj.os.linux:398 fj.lang.c:3410
X-originally-archived-at: http://galaxy.rwcp.or.jp/text/cgi-bin/newsarticle2?ng=fj.lang.c&nb=3410&hd=a
X-reformat-date: Mon, 18 Oct 2004 15:18:22 +0900
X-reformat-comment: Tabs were expanded into 4 column tabstops by the Galaxy's archiver. See http://katsu.watanabe.name/ancientfj/galaxy-format.html for more info.

$BED0f(B@$BC^GHBg$G$9(B.

Koji Masaoka<masaoka@ss.marine.osakafu-u.ac.jp>$B$5$s$O(B
$B5-;v(B<MASAOKA.97Jan7091956@ss.marine.osakafu-u.ac.jp>$B$G$3$&=q$-$^$7$?(B:

>$B$=$3$G!"<!$N$h$&$J<B83MQ$N%W%m%0%i%`$r:n$C$F(B
>$BG[Ns3NJ]$N>e8B$rD4$Y$F$_$k$H(Bdouble$B$N>l9g!"(B
>a[1048100]$B$"$?$j$,G[Ns3NJ]$N>e8B$K$J$C$F$$$k$h$&$G$9!#(B
>[$B;29M(B: 2$B$N(B20$B>h(B=1048576]
>---------------------------------------
>#include <stdio.h>
>
>void main()
>{
>    int n;
>    scanf("%d",&n);
>    {
>        double a[n];
>        printf("%d\n",sizeof(a));
>    }
>}
>---------------------------------------

$B%7%'%k$N(B ulimit $B$G%W%m%;%9;q8;$r@)8B$7$F$$$?$j$7$F(B, 
$B$H$$$&OC$b$"$j$^$9$,(B, $B4pK\E*$KBg$-$JG[Ns$O(B, static
$B$K$9$k$+(B, malloc $B$G<h$k$+$7$J$1$l$P$J$i$J$$$N$@$H;W$$$^$9(B.

double$B$,(B1048100 = $BLs(B8MB $B$G$9$+$i(B, stack $B$O(B 8M $B$^$G(B
$B$H$$$&$3$H$G$O$J$$$+$H;W$$$^$9(B.

$B!t(B $B;d<+?H(B, $BBg$-$JG[Ns$r;H$C$?7W;;$r$5$;$?$3$H$b$J$$$N$G(B,
$B!t(B $B$?$$$=$&$J$3$H$O8@$($^$;$s$,(B... :-)

comp.lang.c $B$N(BFAQ$B$K(B, $B$3$s$J$N$,$"$j$^$9(B.

16.3:   This program crashes before it even runs!  (When single-stepping
        with a debugger, it dies before the first statement in main().)

A:      You probably have one or more very large (kilobyte or more)
        local arrays.  Many systems have fixed-size stacks, and those
        which perform dynamic stack allocation automatically (e.g. Unix)
        can be confused when the stack tries to grow by a huge chunk all
        at once.  It is often better to declare large arrays with static
        duration (unless of course you need a fresh set with each
        recursive call, in which case you could dynamically allocate
        them with malloc(); see also question 1.31).
--
$BED0f=(<y(B $BC^GHBg3XM}9)3X8&5f2J(B
$BEE;R!&>pJs9)3X7O(B $B%W%m%0%i%_%s%08@8l8&5f<<(B
E-mail: tai@softlab.is.tsukuba.ac.jp
