+ 4

What is a memory leak?

Related to pointer and assignments.

15th Apr 2019, 8:45 AM
Akhilesh
Akhilesh - avatar
2 Answers
+ 8
Akhilesh yes it's what HonFu said. Additionally this is only a problem for programs like Servers which run over a long time. If your program is short lived, then leaks are not so much a problem as the memory is released at the end of the running process. This is probably one reason why beginners don't experience the ill effects of a memory leak even if they have one in their code.
15th Apr 2019, 11:25 PM
Sonic
Sonic - avatar
+ 8
If you dynamically require memory on the heap (using 'new'), it will not be freed unless you use 'delete'. If you forget or forgo to delete those areas or you 'lose' the pointers pointing to these areas, they will remain unavailable for other processes. And if you continue this for long enough, there will be reserved spaces all over the heap which you don't use anymore but that also can't be used for anything else, and you run out of space to store new stuff. (That's at least my probably simplistic understanding; C++ pros feel free to add. ;))
15th Apr 2019, 9:36 AM
HonFu
HonFu - avatar