i have allocated memory dynamically with NEW and functionality in which it is implemented will be always keep on running,when i will forcefully terminate it will exit.i Want to deallocate memory also .how i can do that ?
Asked
Active
Viewed 70 times
-2
-
3Dynamically allocated memory will be reclaimed when your process dies. – Anthony Dec 20 '12 at 04:26
-
please be specific or some sample code here not able to get your problem – Prasad Dec 20 '12 at 04:26
1 Answers
4
If the block where you are allocating memory is executed multiple times, then you should think about using smart pointers to deallocate the memory when those objects go out of scope, without you calling delete explicitly.
If the block is executed only once and you want to deallocate memory when the program exits, that is not needed as the OS will reclaim all the memory allocated to your process, irrespective of whether the memory is explicitly deallocated within the process.

Vikdor
- 23,934
- 10
- 61
- 84