Could you explain memory leak in layman lang

kindy exlpain memory leak and give an example for the same.

hello @laksh.rustagi12

memory leak simply means loosing the access of allocated memory.

ie we allocate some memory dynamically but by some mistake we loose its address.
and becuase we loose its address we cannot access it again .

example->
int *a=new int[4] ; //created an array and stored its address in a

a=NULL;//lose the address

…now onwards we cannot access the array beccuase we have lost its address

1 Like