Register now or log in to join your professional community.
Memory leaks happens in C++ because of pointers. Improper handling of pointers will lead to memory leak. Java use garbage collector it will automatically delete all the unwanted memory.
when we are using pointers these are used to store the address of the variable,but by using pointers there is chance of memory leakage i.e chance to know the other variable address i.e insecurity so that's why in place of pointers we are using reference variable to store objects in java.