Unix Programming - what happen to heap on programme exit

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > December 2005 > what happen to heap on programme exit





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author what happen to heap on programme exit
apple.davinci

2005-12-18, 8:49 pm

such as
int main()
{
char * p = new char[44];
char * p1 = new char[33];

p=p1;//memory leak
//and I did't free.


}


what will happen to the heap section when I exit the programme.

Måns Rullgård

2005-12-19, 2:49 am

"apple.davinci" <apple.davinci@gmail.com> writes:

> what will happen to the heap section when I exit the programme.


The OS will reclaim it for use by other processes.

--
Måns Rullgård
mru@inprovide.com
Pascal Bourguignon

2005-12-19, 2:49 am

"apple.davinci" <apple.davinci@gmail.com> writes:

> such as
> int main()
> {
> char * p = new char[44];
> char * p1 = new char[33];
>
> p=p1;//memory leak
> //and I did't free.
>
>
> }
>
>
> what will happen to the heap section when I exit the programme.


It is garbage collected by the OS.


--
__Pascal Bourguignon__ http://www.informatimago.com/
Grace personified,
I leap into the window.
I meant to do that.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com