It's hard to create memory leaks in Java, because Java has automatic memory management (garbage collection). There are ways to have memory leaks, but this will only happen if you keep references to objects that you don't need anymore.
Normally memory leaks are not a big problem in Java applications. If you think you have a memory leak, you should use a profiler to monitor the application and find out what the source of the leak is.
I think you are taking about prevention of memory leak? you no need to worry about it, Java takes care for you. though in some situation you need to code properly such a way that no reference are pointed the obsolete objects.
for example: when you shrink an array , make sure that (removed)references are assigned to a null value.
It sounds like there you're talking about memory use, not memory loss. Yes, it's possible to run out of memory if you use too many resources - e.g. by creating lots of objects that are all still in scope at the same time. If you're in a big loop and creating objects that are only in scope within the loop, though, the garbage collector will be able to clean them out when it needs to.