+ 1

In dynamic memory allocation if we will not deallocate memory using delete operator in c++ then what will happen ???

C++

7th Jul 2020, 3:18 PM
Kajal Kumari
3 Respuestas
+ 2
Thanks to all
7th Jul 2020, 5:31 PM
Kajal Kumari
0
Then you have memory leak in your program, in C++ use Smart pointers like std::shared_ptr instead of raw pointers.
7th Jul 2020, 3:29 PM
قاسم رمضانی
قاسم رمضانی - avatar
0
If you deleted the pointer to the memory somehow then that memory will stay as allocated and will be inaccessible causing a memory leak. This leak is fixed when the progam exits or a system reboots. As per your question, the memory remains allocated until you delete it or the process finishes and causes memory leak.
7th Jul 2020, 3:36 PM
Saphal Poudyal
Saphal Poudyal - avatar