473,225 Members | 1,307 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

Stacks and heaps

I've searched Google and found a few, but I am not so satisfied. Any
good reading on "stacks and heaps" about how and when memory is
allocated from the heap?
Nov 14 '05 #1
6 1641
On 2 Jun 2004 21:14:19 -0700, Vi****************@yahoo.com (Sathyaish)
wrote in comp.lang.c:
I've searched Google and found a few, but I am not so satisfied. Any
good reading on "stacks and heaps" about how and when memory is
allocated from the heap?


The C standard does not specify mechanisms like stacks and heaps.
Memory has three types of storage duration in C programs, static,
automatic, and dynamic.

When, how, and why an implementation provides and manages these types
of memory is up to the implementation. So if you are interested in
how a specific compiler manages memory, you need to ask in a compiler
specific support group.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #2
In <gu********************************@4ax.com> Jack Klein <ja*******@spamcop.net> writes:
On 2 Jun 2004 21:14:19 -0700, Vi****************@yahoo.com (Sathyaish)
wrote in comp.lang.c:
I've searched Google and found a few, but I am not so satisfied. Any
good reading on "stacks and heaps" about how and when memory is
allocated from the heap?
The C standard does not specify mechanisms like stacks and heaps.


These are data structures, not mechanisms.
Memory has three types of storage duration in C programs, static,
automatic, and dynamic.

When, how, and why an implementation provides and manages these types
of memory is up to the implementation. So if you are interested in
how a specific compiler manages memory, you need to ask in a compiler
specific support group.


There is nothing compiler specific in understanding how these data
structures can be used to implement automatic and dynamic memory
allocation.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #3
Sathyaish wrote:
I've searched Google and found a few, but I am not so satisfied. Any
good reading on "stacks and heaps" about how and when memory is
allocated from the heap?


Often times, compilers use a heap for managing dynamic memory.
Dynamic memory is memory that is set aside for the program to
use during run-time.

Most of the time, programs use the *alloc() family of functions
to allocate from dynamic memory. The memory stays allocated until
either the program deallocates the memory via free or the
program is terminated (and the memory is re-used by the operating
system).

Dynamic memory often is used when the amount cannot be determined
during compile time, or when the program needs more memory than
the compiler can allocate during compile time (or program load
time).

Linked lists are a classic example of using dynamic memory
allocation.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Nov 14 '05 #4
Thanks, Thomas and others. I want some more rigorous reading on this.
For instance, I could easily understand what Thomas Matthews said
because I knew it earlier plus I have some background of C and C++.
Where can I get more copious information on the internal working of
the heap?

PS: Thomas, haven't I seen you on JoS?
Nov 14 '05 #5
Sathyaish wrote:
Thanks, Thomas and others. I want some more rigorous reading on this.
For instance, I could easily understand what Thomas Matthews said
because I knew it earlier plus I have some background of C and C++.
Where can I get more copious information on the internal working of
the heap?
The heap is a tool (data structure) used by some compiler vendors to
manage dynamic memory. An implementation is not required to have
a heap in order to be compliant with the standard.

The question now is whether you want copious information about:
1. Heap data structures
2. Memory allocation methods (schemes)
3. Compiler Theory.
I suggest using your favorite web search engine with the appropriate
keywords and see what you can find. I took and older route and took
classes in the above at the University. Many Universities give the
Computer Science people a Compiler to write as their final project.

As far as the C language goes, you can do three things with
dynamic memory:
1. Allocate from it.
2. Reallocate from it.
2. Deallocate objects to it (i.e. return or free already
allocated items).
Kind of simple and boring. You allocate memory as you need it
and dispose of the objects when you are finished with them.
Anything beyond this, such as alignment and memory collection,
is beyond the scope of this newsgroup.


PS: Thomas, haven't I seen you on JoS?

What is JoS?
I remember playing with an operating system called JOSS, but
that was a long time ago.

If you know me, you might remember that I really hate acroynyms.
Just as a picture is worth a thousand words, one never really
knows which of those thousand words the author/artist was meaning
to convey. I prefer to be explicit. So, WTF is JoS?
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Nov 14 '05 #6
That answers it. The Joel On Software site, a wonderful site about
software development issues, is more fondly known by its members as
JoS. Thanks for the info. I wish I'd gone to a university for a
Computer Science degree when my parents couldn't afford to send me.

Regards,
Sathyaish Chakravarthy.

Thomas Matthews <Th****************************@sbcglobal.net> wrote in message news:<fM*************@newssvr16.news.prodigy.com>. ..
Sathyaish wrote:
Thanks, Thomas and others. I want some more rigorous reading on this.
For instance, I could easily understand what Thomas Matthews said
because I knew it earlier plus I have some background of C and C++.
Where can I get more copious information on the internal working of
the heap?


The heap is a tool (data structure) used by some compiler vendors to
manage dynamic memory. An implementation is not required to have
a heap in order to be compliant with the standard.

The question now is whether you want copious information about:
1. Heap data structures
2. Memory allocation methods (schemes)
3. Compiler Theory.
I suggest using your favorite web search engine with the appropriate
keywords and see what you can find. I took and older route and took
classes in the above at the University. Many Universities give the
Computer Science people a Compiler to write as their final project.

As far as the C language goes, you can do three things with
dynamic memory:
1. Allocate from it.
2. Reallocate from it.
2. Deallocate objects to it (i.e. return or free already
allocated items).
Kind of simple and boring. You allocate memory as you need it
and dispose of the objects when you are finished with them.
Anything beyond this, such as alignment and memory collection,
is beyond the scope of this newsgroup.


PS: Thomas, haven't I seen you on JoS?

What is JoS?
I remember playing with an operating system called JOSS, but
that was a long time ago.

If you know me, you might remember that I really hate acroynyms.
Just as a picture is worth a thousand words, one never really
knows which of those thousand words the author/artist was meaning
to convey. I prefer to be explicit. So, WTF is JoS?
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Nov 14 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Vanessa T. | last post by:
Hello All! Is there a place where I can learn stacks, (push and pop) etc. Thanks,
4
by: Ice | last post by:
Hi there, I'm not sure if this is the right group for this- If it isn't, could anyone point me in the right direction? For our data structures exam, we are usually asked to implement the...
18
by: pmm | last post by:
Hi all, Plz dont fire at me if this is a silly question Is there any way to know in which direction stack grows pmm
10
by: Rich Kucera | last post by:
Holding all versions at 5.0.4, Multiple stacks with multiple-version configurations inevitable Will have to wait to see what the impact of problems such as http://bugs.php.net/bug.php?id=33643 ...
2
by: Daniel | last post by:
Hi, I have a question regarding the memory managment in stl stacks. I want to use stacks to store a very large amount of numbers (some millions), thus I'm interested in how the stack behaves...
0
by: raghuveer | last post by:
i want to implement multiple stacks using arrays..I am able to create ,insert and print them but not poping an element form any of the stack..This is what i have #include<stdio.h>...
2
by: John Grandy | last post by:
Are Gen 0, Gen 1, Gen 2 heaps and Large Object Heaps physically contiguous ? Or are these abstract representations of groups of allocated segments in the general heap ? More specifically, are the...
8
by: cerise | last post by:
I can't figure out how to make and handle multiple stacks and use them so I could create four linked list stacks representing each suit of cards, one stack each for diamonds, hearts, spades, and...
3
by: abhishek | last post by:
Hi group any idea on HOW TO HANDLE POINTERS FROM NON-LOCAL HEAPS?? Thank you
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.