if this error occured after adding sme piece of code to an already running application, then your new code have created a lot of objects and filled the heap size and lead to outof memory err.\
Check for
1. Any recursive calls which create a lot of objects 2. Check for the scope of the objects, may be you were trying to add objects to a static container object. Hence objects were not eligible for Garbage collection. 3. Any socket related operations that lead to consuming a lot of resources.
In simple, your code is stopping GC from doing its work !!(by keeping live references for unnecessary objects)
Actully i have changed JVM heap memory -Xms to something i have changed it after doing this thing it's give me the error. So anyone know how to fix it. I have removed the -Xms.
This is a JVM parameters u set when u execute ur Program. the Xms set the initial Heap size. When u allocate very less space, u probably get this error.