Home > DeveloperSection > Forums > What are memory leaks in java
David Miller

Total Post:30

Points:210
Posted on    September-04-2015 7:20 AM

 Java Java 
Ratings:


 1 Reply(s)
 1871  View(s)
Rate this:
I am very confused about memory management in java, what is memory leaks and when will it occurs


Mayank Tripathi
Mayank Tripathi

Total Post:397

Points:3117
Posted on    September-04-2015 7:36 AM

We think that Java’s automatic garbage collection completely frees them from worrying about memory management. This is a common misperception: while the garbage collector does its best, it’s entirely possible for even the best programmer to fall prey to crippling memory leaks

A memory leak occurs when object references that are no longer needed are unnecessarily maintained. These leaks are bad. For one, they put unnecessary pressure on your machine as your programs consume more and more resources

There actually four categories of memory issues with similar and overlapping symptoms, but varied causes and solutions:

Performance: usually associated with excessive object creation and deletion, long delays in garbage collection, excessive operating system page swapping, and more.
Resource constraints: occurs when there’s either to little memory available or your memory is too fragmented to allocate a large object—this can be native or, more commonly, Java heap-related.
Java heap leaks: the classic memory leak, in which Java objects are continuously created without being released. This is usually caused by latent object references.
Native memory leaks: associated with any continuously growing memory utilization that is outside the Java heap, such as allocations made by JNI code, drivers or even JVM allocations.


Don't want to miss updates? Please click the below button!

Follow MindStick