Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Deallocating dynamically allocated heap

This is a discussion on Deallocating dynamically allocated heap within the C and C++ forums, part of the Software Development category; When i am dynamically allocating memory (heap) in a program, and in this case if i am not making an explicit deallocation call or free() call then when will this ...

Go Back   Geeks Talk > Software Development > C and C++
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 01-07-2007
Expert Member
 
Join Date: Oct 2006
Posts: 689
Thanks: 0
Thanked 53 Times in 44 Posts
JobHelper is on a distinguished road
Deallocating dynamically allocated heap

When i am dynamically allocating memory (heap) in a program, and in this case if i am not making an explicit deallocation call or free() call then when will this dynamicaaly allocated heap will get deallocated.Is it at the end of program or is it at the end of c session or is it when i shut down my system.

NOTE : [This question was asked by Leomachy]
Reply With Quote
The Following User Says Thank You to JobHelper For This Useful Post:
Sponsored Links
  #2 (permalink)  
Old 07-24-2007
Contributing Member
 
Join Date: Jul 2007
Location: India
Posts: 31
Thanks: 6
Thanked 4 Times in 4 Posts
kamanianil is on a distinguished road
Re: Deallocating dynamically allocated heap

i think you get solution by follow the following steps:

-->write some C, c++ any code which will alocate some memory.
-->note down the address where you are allocating the memory.
-->Now meanwhile write and open another C program, which will display the
content of memory that you are allocating previously.
-->for the first program ,,,end the session and check in the second C program.
-->
Reply With Quote
  #3 (permalink)  
Old 07-24-2007
Contributing Member
 
Join Date: Jul 2007
Location: India
Posts: 31
Thanks: 6
Thanked 4 Times in 4 Posts
kamanianil is on a distinguished road
Re: Deallocating dynamically allocated heap

i think you get solution by follow the following steps:

-->write some C, c++ any code which will alocate some memory.
-->note down the address where you are allocating the memory.
-->Now meanwhile write and open another C program, which will display the
content of memory that you are allocating previously.
-->for the first program ,,,end the session and check in the second C
program.
--> same way quit from the application and check in the second C program
memory content.
....................
-->
Reply With Quote
  #4 (permalink)  
Old 07-24-2007
Junior Member
 
Join Date: Jul 2007
Location: Noida
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
ashwini165 is on a distinguished road
Re: Deallocating dynamically allocated heap

Quote:
Originally Posted by JobHelper View Post
When i am dynamically allocating memory (heap) in a program, and in this case if i am not making an explicit deallocation call or free() call then when will this dynamicaaly allocated heap will get deallocated.Is it at the end of program or is it at the end of c session or is it when i shut down my system.

NOTE : [This question was asked by Leomachy]

When a malloc() is called some physical memory is mapped on to your process address space. When your process will ends up this memory will return to the system.
Reply With Quote
  #5 (permalink)  
Old 07-25-2007
Junior Member
 
Join Date: Jun 2007
Location: India
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
shine_babu is on a distinguished road
Re: Deallocating dynamically allocated heap

The allocated memory will last till you process ends. But this is not a good practice, u shuld deallocate the memory what u allocate else it can cause memory leak and your system will crash
Reply With Quote
Reply

  Geeks Talk > Software Development > C and C++

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
How to check planidrome dynamically? JobHelper C and C++ 1 07-27-2007 01:47 AM
Dynamically pass parameter file in 8.1.1 JobHelper Data Warehousing 0 12-24-2006 06:30 AM


All times are GMT -4. The time now is 07:13 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2005 - 2010 GeekInterview.com. All Rights Reserved