Re: Stacks and heaps

From: Thomas Matthews (Thomas_MatthewsSpitsOnSpamBots_at_sbcglobal.net)
Date: 06/03/04


Date: Thu, 03 Jun 2004 13:23:11 GMT

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


Relevant Pages

  • Re: Memory Limit for Visual Studio 2005???
    ... whenever memory allocated exceeds 256 MB. ... I could not get Visual Studio 2005 Express to allocate more than 256 MB without abnormally terminating. ... I was very pleased with its relative performance to Native Code Visual C++ 6.0. ... the std::vector template will compile as a native class .Try to compile in pure managed mode /clr:safe and it will fail. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: data exchange between two windows
    ... 'new' is designed to allocate dynamic memory. ... You won't find much of a discussion of malloc in the C/C++ reference, ... Of course, you could allocate a pointer, although that is not a common ...
    (microsoft.public.vc.mfc)
  • Re: Memory Limit for Visual Studio 2005???
    ... whenever memory allocated exceeds 256 MB. ... If you have actually tested this and thus know that it works empirically rather than theoretically, then this must be a limitation of Visual Studio 2005 Express. ... I could not get Visual Studio 2005 Express to allocate more than 256 MB without abnormally terminating. ... There is no such thing like MANAGED std::vector, and the program should compile just fine from the command line. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: how to allow large static space allocation in c/c++?
    ... using allocato allocate stack space on the fly. ... > just three big arrays, but after I compile and run this program, I was ... > might not gunrantee consecutive memory space, ...
    (comp.unix.programmer)
  • Re: Memory Limit for Visual Studio 2005???
    ... exception whenever memory allocated exceeds 256 MB. ... I could not get Visual Studio 2005 Express to allocate more ... try to compile and run your code from the command-line ...
    (microsoft.public.dotnet.languages.csharp)