Re[2]: maximum number of variables?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




ILT> Bob Rossi <bob@xxxxxxxxxx> 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?

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

ILT> Ian


Ian,

  I did ulimit -s and ulimit -v in a solaris 9 sun machine. ulimit -s returns 8192, ok, but ulimit -s returns unlimited. Does this make sense?


Miguel Angel


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux