What is meant by memory leak in a program? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

What is meant by memory leak in a program?

it is written in chapter dynamic memory if delete keyword is not used then there are memory leaks in the program

13th Feb 2017, 3:39 AM
vaibhav tomar
vaibhav tomar - avatar
4 Antworten
+ 2
thanks pal
13th Feb 2017, 4:24 AM
vaibhav tomar
vaibhav tomar - avatar
+ 1
When your program continually or periodically takes up more and more memory.
13th Feb 2017, 3:55 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
chaotic buddy could u plz elaborate, it would be a great help
13th Feb 2017, 4:03 AM
vaibhav tomar
vaibhav tomar - avatar
+ 1
Let's say we created a program in which we make a variable that allocates memory in a function and then never deallocates that memory when finished using that variable. Then later in the program the end user performs another task that uses this function so once again we allocate memory within the function and never deallocate it. for instance: void myFunc( ) { int *obj = new int; *obj = 256; // allocate 256 of int size in memory (usually 4 bytes each = 1024 bytes total) // do some work with obj // obj is never deallocated leaving it hanging around in memory } myFunc(); myFunc();
13th Feb 2017, 4:22 AM
ChaoticDawg
ChaoticDawg - avatar