+ 3

Does the memory space remains same after deletion of object?

18th Sep 2017, 12:19 PM
Mariyam Beebi
Mariyam Beebi - avatar
4 Answers
+ 7
Depends on the language. For example, In Java or C# there is a garbage collector, that will do as what @Rose said. The memory will be freed when the garbage collector decides to free it (The programmer doesn't really know when, It could be after there is x amount of 'garbage' to collect). Although, there might be ways for the programmer to force the garbage collector to free up the memory at a specific time. (Also depending on the language). Meanwhile, other languages that do not have a garbage collector such as C++, require the programmer to free the memory. If the memory is never freed and more objects are created, a memory leak can occur. The leak will occur when there is no memory left to allocate.
18th Sep 2017, 3:58 PM
Rrestoring faith
Rrestoring faith - avatar
+ 4
If I understand things right - even if you'll delete links to object in your code - it's value will still be saved in memory UNTIL garbage collector will remove it.Timings may be different, even if it should delete it right after all related links was removed and all functions,using it was completed.
18th Sep 2017, 12:29 PM
Rose Sevenyears
Rose  Sevenyears - avatar
+ 2
seriously I don't know the answer.. I have posted the question for the right answer..
18th Sep 2017, 3:39 PM
Mariyam Beebi
Mariyam Beebi - avatar
+ 2
the answer is - memory usage will be less,but not instantly.
18th Sep 2017, 3:42 PM
Rose Sevenyears
Rose  Sevenyears - avatar