The heap

This is a discussion on The heap within the C++ Programming forums, part of the General Programming Boards category; I just recently read about the heap in my new book, and im wondering how important is it to have ...

  1. #1
    Programmer Frantic-'s Avatar
    Join Date
    Dec 2004
    Posts
    114

    The heap

    I just recently read about the heap in my new book, and im wondering how important is it to have a good background in this? Is the stack really that small? When writing normal applications or games, will I need to use the heap alot, or only for extreme cases?

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Is the stack really that small?
    I don't think the size of the stack has anything to do with where objects are stored. The method used to create an object determines where it is stored. Depending on what you do, an object can be created on the stack or on the heap.

    For now, don't worry about it.

  3. #3
    C/C++Newbie Antigloss's Avatar
    Join Date
    May 2005
    Posts
    212
    From C++ Primer, Fourth Edition By Stanley B. Lippman, Josée Lajoie, Barbara E. Moo

    Every program has a pool of available memory it can use during program execution to hold dynamically allocated objects. This pool of available memory is referred to as the program's free store or heap. C programs use a pair of functions named malloc and free to allocate space from the free store. In C++ we use new and delete expressions.

    A variable of array type has three important limitations: Its size is fixed, the size must be known at compile time, and the array exists only until the end of the block in which it was defined. Real-world programs usually cannot live with these restrictionsthey need a way to allocate an array dynamically at run time. Although all arrays have fixed size, the size of a dynamically allocated array need not be fixed at compile time. It can be (and usually is) determined at run time. Unlike an array variable, a dynamically allocated array continues to exist until it is explicitly freed by the program.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. heap
    By George2 in forum Windows Programming
    Replies: 2
    Last Post: 11-10-2007, 10:49 PM
  2. Heap Work
    By AndyBomstad in forum C++ Programming
    Replies: 1
    Last Post: 05-16-2005, 12:09 PM
  3. Do you know...
    By davejigsaw in forum C++ Programming
    Replies: 1
    Last Post: 05-10-2005, 10:33 AM
  4. heap question
    By mackol in forum C Programming
    Replies: 1
    Last Post: 11-30-2002, 04:03 AM
  5. stach and heap.
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 01-26-2002, 08:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21