What is memory pool

B

bull

hi
could any one explain with example the following in a better way to
understand
1. what is stack in memory, how the programs are stored in stack , what
is the use of stack
2. What is heap in memory, how the programs are stored in heap , what
is the use of heap
3. what is pool memory otherwise memory pool, what is the use of memory
pool
4. what is difference between stack and heap
5. what is the difference b/w pool and stack
6. what is the difference b/w pool and heap




thanks in advance
 
A

Allan Bruce

bull said:
hi
could any one explain with example the following in a better way to
understand
1. what is stack in memory, how the programs are stored in stack , what is
the use of stack
2. What is heap in memory, how the programs are stored in heap , what is
the use of heap
3. what is pool memory otherwise memory pool, what is the use of memory
pool
4. what is difference between stack and heap
5. what is the difference b/w pool and stack
6. what is the difference b/w pool and heap




thanks in advance

These concepts are all irrelevant as far as c programming is concerned.
Allan
 
C

CBFalconer

bull said:
could any one explain with example the following in a better way
to understand
1. what is stack in memory, how the programs are stored in stack ,
what is the use of stack
2. What is heap in memory, how the programs are stored in heap ,
what is the use of heap
3. what is pool memory otherwise memory pool, what is the use of
memory pool
4. what is difference between stack and heap
5. what is the difference b/w pool and stack
6. what is the difference b/w pool and heap

None of those things necessarily exist in C. We have automatic
memory, which is allocated on function entry and deallocated on
function exit, and static memory, which is allocated until program
completion. A subset of static memory is controlled memory,
assigned by malloc, realloc, and calloc, and released by free.
Where and how these things are supplied has nothing to do with a C
program.

Some systems use a stack for automatic memory, but this is not the
only possible method.
 
T

Thomas Matthews

bull said:
hi
could any one explain with example the following in a better way to
understand
These are general programming questions and best discussed in
Followups set.
1. what is stack in memory, how the programs are stored in stack , what
is the use of stack
Stack memory is memory that is treated like a stack of dishes:
first in, first out (FIFO).

I don't know of any programs that are stored in stack memory, but
that doesn't mean there aren't any.

Many programs use stack memory for temporary variables and also to
store return addresses. The stack data structure is convenient here
because the temporary variables can be "popped" off, restoring the
memory area to where it was before the temporary variables were
created. Search the web for "data structure stack" for more
information (or read a good text book on data structures).

2. What is heap in memory, how the programs are stored in heap , what
is the use of heap
Generally speaking, a heap of memory is an area of memory that the
program uses for run-time allocation of data.

Programs can be stored in the heap, but I don't know of any
languages that store functions in a heap. Although one could
consider the memory that the operating system uses as a heap
and a program is loaded into this heap and executed. To
store a program in the heap, just move the executable code
into the heap.

3. what is pool memory otherwise memory pool, what is the use of memory
pool
A memory pool is a vague concept. Sometimes it is a synonym
for a heap. Other times it is memory shared by more than
one task. Another definition is an area reserved by the
program for allocation; versus a heap used by the language
or operating system.

4. what is difference between stack and heap
5. what is the difference b/w pool and stack
6. what is the difference b/w pool and heap




thanks in advance


--
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.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
 
D

dot

On Thu, 31 Mar 2005 11:52:10 +0200, bull

First, you should be looking in the documentation for your version of C for
information like this. It varies quite a bit from platform to platform and
compiler to compiler...
1. what is stack in memory, how the programs are stored in stack , what
is the use of stack

The stack is a region of memory, assigned to a program, used by the CPU for
subroutine return addresses and temporary storage of register contents.
Some languages also use the stack for storage of temporary variables and
passing of function parameters. It's not generally considered "user
available".

Far as I know, programs are never stored on the stack.

2. What is heap in memory, how the programs are stored in heap , what
is the use of heap

The heap (in general parlance) is a chunk of memory assigned to a program.
It's your playspace for making arrays, structures, lists etc. To reserve
memory you use "malloc", "calloc" or "realloc". To release it you use
"free". In general you must release all memory you've reserved.

Programs are not stored in the heap, this is data space used by programs.
3. what is pool memory otherwise memory pool, what is the use of memory
pool

This is the sum of free memory available to all programs currently running
on a system. i.e. the memory not assigned to stacks, heaps, or programs.

4. what is difference between stack and heap

Each program's stack exists within the memory pool. However the stack is
treated very differently than other memory... pile up some wooden blocks on
top of one another, in a single column... now add a couple and remove a
couple... this is how the stack works. Put on top, take from the top,
otherwise disaster follows. This is called Last In First Out, or LIFO for
short.
5. what is the difference b/w pool and stack

A program's stack exists inside the memory pool.
6. what is the difference b/w pool and heap

A program's heap exists within the memory pool.



As for the examples [grin]... let's call that a homework assignment...
 
K

Keith Thompson

CBFalconer said:
None of those things necessarily exist in C. We have automatic
memory, which is allocated on function entry and deallocated on
function exit, and static memory, which is allocated until program
completion. A subset of static memory is controlled memory,
assigned by malloc, realloc, and calloc, and released by free.
Where and how these things are supplied has nothing to do with a C
program.

A terminology quibble: I don't think the term "static" applies to
malloc()-allocated memory.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,427
Latest member
HildredDic

Latest Threads

Top