In C, programmers totally control allocation and deallocation of dynamically created objects. And if a programmer does not destroy objects, memory leak happens in C,
Java does automatic Garbage collection. However there can be situations where garbage collector does not collect objects because there are references to them. There might be situations where where an application creates lots of objects and does not use them. Just because every objects has valid references, garbage collector in Java can’t destroys the objects. Such types of useless objects are called as Memory leaks. If allocated memory goes beyond limit, program will be terminated by rising OutOfMemoryError. Hence if an object is no longer required, it is highly recommended to make that object eligible for garbage collector. Otherwise We should use some tools that do memory management to identifies useless objects or memeory leaks like:
- HP OVO
- HP J METER
- IBM Tivoli
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space exceed
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- How to find max memory, free memory and total memory in Java?
- Java Memory Management
- How are Java objects stored in memory?
- Thread Interference and Memory Consistency Errors in Java
- Java substring() method memory leak issue and fix
- How many types of memory areas are allocated by JVM?
- Java.util.LinkedList.poll(), pollFirst(), pollLast() with examples in Java
- Java.util.Collections.disjoint() Method in java with Examples
- Java.util.LinkedList.offer(), offerFirst(), offerLast() in Java
- Java.util.Collections.rotate() Method in Java with Examples
- Java.util.LinkedList.peek() , peekfirst(), peeklast() in Java
- Java.util.concurrent.Phaser class in Java with Examples
- Java.util.concurrent.RecursiveTask class in Java with Examples
- Java.lang.Short toString() method in Java with Examples
- Java lang.Long.highestOneBit() method in Java with Examples
- Java.util.function.DoublePredicate interface in Java with Examples
- Java.util.concurrent.RecursiveAction class in Java with Examples
- Java lang.Long.numberOfLeadingZeros() method in Java with Examples
- Java lang.Long.lowestOneBit() method in Java with Examples
- Java Deprecated API Scanner tool (jdepscan) in Java 9 with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.