Heap vs Stack
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Heap vs Stack




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Heap vs Stack  
Nehil


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-08-07 12:22 PM

I would like to know which is dynamic in nature.
if i refer the C memory model (Richard Steven), it is shown that both
stack and heap grow towards each other.
Now, can one go into other's area and hence effecting the size of
other memory area.

Does any limit exist upto which a stack or a heap can grow. and if it
is there then who decides the limit?

plz clarify.






[ Post a follow-up to this message ]



    Re: Heap vs Stack  
David T. Ashley


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-08-07 06:21 PM

"Nehil" <nehilparashar@gmail.com> wrote in message
news:1183894832.890803.254790@r34g2000hsd.googlegroups.com...
>I would like to know which is dynamic in nature.
> if i refer the C memory model (Richard Steven), it is shown that both
> stack and heap grow towards each other.
> Now, can one go into other's area and hence effecting the size of
> other memory area.
>
> Does any limit exist upto which a stack or a heap can grow. and if it
> is there then who decides the limit?

Stack and heap are in some sense related concepts, except for the required
order of release.  It is not uncommon with certain development tools to have
functions that will claim space on the stack and return a pointer (similar
to malloc).  However, such claimed areas have to be released from the bottom
up (they can't be preserved when a function returns).

In a modern operating system (on modern hardware), the limit is typically a
feature of the operating system on the platform.  4GB is typical.  It
doesn't normally make sense to have this limit configurable -- with modern
hardware (pages, page faults, and all that) the system can normally move
stuff around as the program's memory needs grow until the limit is reached.
--
David T. Ashley              (dta@e3ft.com)
http://www.e3ft.com          (Consulting Home Page)
http://www.dtashley.com      (Personal Home Page)
http://gpl.e3ft.com          (GPL Publications and Projects)







[ Post a follow-up to this message ]



    Re: Heap vs Stack  
Scott Lurndal


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-09-07 06:26 PM

Nehil <nehilparashar@gmail.com> writes:
>I would like to know which is dynamic in nature.
>if i refer the C memory model (Richard Steven), it is shown that both
>stack and heap grow towards each other.
>Now, can one go into other's area and hence effecting the size of
>other memory area.
>
>Does any limit exist upto which a stack or a heap can grow. and if it
>is there then who decides the limit?
>
>plz clarify.
>
$ ulimit -aS
address space limit (kbytes)   (-M)  unlimited
core file size (blocks)        (-c)  0
cpu time (seconds)             (-t)  unlimited
data size (kbytes)             (-d)  unlimited
file size (blocks)             (-f)  unlimited
locks                          (-L)  unlimited
locked address space (kbytes)  (-l)  32
nofile                         (-n)  1024
nproc                          (-u)  16383
pipe buffer size (bytes)       (-p)  4096
resident set size (kbytes)     (-m)  unlimited
socket buffer size (bytes)     (-b)  4096
stack size (kbytes)            (-s)  10240
threads                        (-T)  not supported
process size (kbytes)          (-v)  unlimited

'stack size' defines the maximum amount of space that can
be used by the stack.   'data size' bounds the heap. These
are per-process limits.

see man setrlimit, pam_limits, man ulimit, et. al.

scott





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:10 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register