Saturday 29 August 2015

Java Memory Leak Cause

 In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations[1] in such a way that memory which is no longer needed is not released. In object-oriented
programming, a memory leak may happen when an object is stored in memory but cannot be accessed by the running code.[2] A memory leak has symptoms similar to a number of other problems (see below) and generally can only be diagnosed by a programmer with access to the program's source code. Here are the typical cause of  Memory Leak In Java:

1. Do not close DB, file, socket, JMS resources and other external resources properly.

2. Do not close resources properly when an exception is thrown.

3.  Keep adding objects to a cache or a hash map without expiring the old one.

3. Do not implement the hash and equal function correctly for the key to a cache

4. Leak in third party library or the application server

5. Bugs in the JDK.

6. In an infinite application code loop.

7. Leaking memory in the native code

9. Session data is too large.

 

No comments:

Post a Comment