William said:
to be
argument to
allocated memory
is one
Out of curiosity (and I know that the standard does not mandate
any specific way) but are the mechancis of this something that is
usually handled by the program code (the stuff thrown in by the
compiler) or are the mechanics generally done by the operating
system?
The mechanics are up to the compiler implementor. Some compilers
have their own memory allocation schemes. Others use the operating
systems memory management routines. Still other compilers allow
users to provide their own.
There is nothing stopping program code from implementing
its own memory management.
Which side of the house, more often than not, keeps track
of this?
Probably the dark side; could be the section between the
ceiling and the bottom of the upper floor (where the pipes
may live).
Most programs leave memory management up to the compiler
implementation. Some non-portable programs may use the
operating system features. And yet other programs implement
their own memory management scheme. The simplest method
is to use the language memory allocation features and don't
worry _how_ it is implemented. There are more important
topics to worry about, such as program correctness, than
what operates under the hood of a language.
Would it be reasonable (not necessarily right and
certainly not guaranteed to be right) to suspect that with
smaller code sizes (memory models) that the program's "heap"
space is a block of memory that the OS gave it as start up and
the program manages the assignment requests within that block but
if you are working with a program that can request, at least
cumulatively, hundreds of megabytes of dynamic memory that the
program requests additional memory from the OS (perhaps in fewer,
but larger chunks) and the OS keeps track of the butcher's bill
for that?
Could be reasonable, could not be. Depends.
Many multi-user systems have different memory sizes set aside
for different users. Some operating systems implement a paging
system, where the program is given a "page" of memory and any
allocation beyond that page cause another one to be loaded in.
Some systems have a fixed memory size regardless of the executable
code size.
Executable code size has no relationship to the amount of memory
required by the executable program. A small program can be written
that uses a lot of memory while a large program can be written
that uses very little memory.
Focus on completing the program and getting all the bugs out
(correctness) before even thinking about how much memory it
needs, how fast it is or the size of the code. The latter
topics can all be optimized after profiling the program.
--
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