Results 1 to 3 of 3

Thread: Heap and stack memory

  1. #1

    Heap and stack memory

    hi everybody,
    wishing all people very best of life time...

    what is differance between Stack and Heap memory with this concept used in C++

    thanks


  2. #2
    Junior Member
    Join Date
    Apr 2009
    Answers
    2

    Re: Heap and stack memory

    Stack


    When a function or a method calls another function which in turns calls another function etc., the execution of all those functions remains suspended until the very last function returns its value.

    This chain of suspended function calls is the stack, because elements in the stack (function calls) depend on each other.

    The stack is important to consider in exception handling and thread executions.

    Heap
    The heap is simply the memory used by programs to store variables.
    Element of the heap (variables) have no dependencies with each other and can always be accessed randomly at any time.


  3. #3
    Junior Member
    Join Date
    Mar 2010
    Answers
    4

    Thumbs up Re: Heap and stack memory

    When variables are created in a C++ program the memory required to hold the variable is allocated from the program stack,and when the variable goes out of scope, the memory which was taken on the stack is freed.

    When memory is allocated dynamically (by the programmer) memory is taken from the heap .

    In C++ memory is allocated dynamically using the new operator.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact