public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <ian@airs.com>
To: Bob Rossi <bob@brasko.net>
Cc: Lexington Luthor <lexington.luthor@gmail.com>, gcc-help@gcc.gnu.org
Subject: Re: maximum number of variables?
Date: Wed, 31 Aug 2005 04:20:00 -0000	[thread overview]
Message-ID: <m364tmn3g8.fsf@gossamer.airs.com> (raw)
In-Reply-To: <20050831010044.GA2661@white>

Bob Rossi <bob@brasko.net> writes:

> On Tue, Aug 30, 2005 at 10:54:02PM +0100, Lexington Luthor wrote:
> 
> > I think for large arrays, its best to allocate them from the heap. Use 
> > malloc() or new (if using C++).
> 
> I've always been told that the heap and stack grow towards each other.
> If this is true, why would it be OK to create the item on the heap, vs
> on the stack? If it's not true, could someone simply explain how this
> works?

You are correct in theory.  In practice the heap and stack have
different limits, and the limit on the heap is much larger than the
stack (if running bash, compare ulimit -s and ulimit -v).  And if you
worry about portability, on some platforms allocating a large stack
frame will simply fail, and on some other platforms it will require
extra work to emit stack probes to tell the OS that you are
intentionally extending the stack rather than just referencing a
random memory address.

Ian

  reply	other threads:[~2005-08-31  4:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-30 21:01 Nicolas Ouellette
2005-08-30 21:08 ` Bob Rossi
2005-08-30 21:41   ` Nicolas Ouellette
2005-08-30 22:13     ` Lexington Luthor
2005-08-31  1:01       ` Bob Rossi
2005-08-31  4:20         ` Ian Lance Taylor [this message]
2005-08-31  9:13           ` Re[2]: " Miguel A. Nuñez
2005-08-31 11:17             ` Bob Rossi
2005-09-01  8:20               ` Re[2]: " Miguel A. Nuñez
2005-08-31 11:19           ` Bob Rossi
2005-08-30 23:01 ` corey taylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m364tmn3g8.fsf@gossamer.airs.com \
    --to=ian@airs.com \
    --cc=bob@brasko.net \
    --cc=gcc-help@gcc.gnu.org \
    --cc=lexington.luthor@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).