How to Handle Memory leaks in Java Program

 

This article addresses the how to handle memory leaks in java program. One common indication of a memory leak is the  java.lang.OutOfMemoryError error.It is big Issue even though it is handled by Garbage Collector in Java.
If you are working for big java project memory leaks impact will be more.
Here we will see some solutions for java memory leaks problem.
Solutions for Java Memory leaks
1.Collection classes, such as hash tables and vectors, are common places to find the cause of a memory leak.
2.Unregister when the class is no longer needed. Otherwise it will exist until the application close.
3.Integrate your java application with JProfiler so that you can check which class or method is taking more memory.
4.If you are application using database ensure that tables are not containing unwanted data [historical data].otherwise it will load every time when application starts and collection classes’ size will increase.
5.Application design is also an important factor for memory leak. If possible do changes in design level.

Related posts:

  1. How to Handle Concurrentmodificationexception in Java
  2. How to allocate memory for structure pointer using new operator in C++

Comments are closed.