excess allocation in heap segment of a process - Unix

This is a discussion on excess allocation in heap segment of a process - Unix ; Hi Everyone, We all know that when the stack segment overflows, we get a error saying stack overflow and the program terminates. A main() calling itself recursivley results in this, What happens when the heap segment overflows? when we keep ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: excess allocation in heap segment of a process

  1. excess allocation in heap segment of a process

    Hi Everyone,

    We all know that when the stack segment overflows, we get a error
    saying stack overflow and the program terminates. A main() calling
    itself recursivley results in this,

    What happens when the heap segment overflows? when we keep on
    allocating dynamic memory in a loop...

    Thanks in advance!!!


  2. Re: excess allocation in heap segment of a process

    sam_cit@yahoo.co.in wrote:
    > We all know that when the stack segment overflows, we get a error
    > saying stack overflow and the program terminates. A main() calling
    > itself recursivley results in this,
    >
    > What happens when the heap segment overflows? when we keep on
    > allocating dynamic memory in a loop...


    Why would you keep on trying to allocate memory when you are
    checking the return value from malloc() (or whatever) and it is
    telling you there is no more memory left to allocate?

    At any rate, I suppose what would happen is that you would end
    up wasting a lot of CPU time.

    - Logan

  3. Re: excess allocation in heap segment of a process

    On Apr 25, 6:27 pm, sam_...@yahoo.co.in wrote:
    > Hi Everyone,
    >
    > We all know that when the stack segment overflows, we get a error
    > saying stack overflow and the program terminates. A main() calling
    > itself recursivley results in this,
    >
    > What happens when the heap segment overflows? when we keep on
    > allocating dynamic memory in a loop...
    >
    > Thanks in advance!!!


    I think the correct behavior is malloc() returns NULL.


+ Reply to Thread