+ 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
4 Réponses
+ 2
thanks pal
+ 1
When your program continually or periodically takes up more and more memory.
+ 1
chaotic buddy could u plz elaborate, it would be a great help
+ 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();