1. Analyze heap dump.
2. Use jVisualVM to figure out the biggest object and analyze if that size could be reduced.
3. Find out objects that are unnecessarily referenced for long time and that can be dereferenced to free some memory.
4. Increase the heap size If memory allocation is not sufficient
5. Don't keep the variables referenced for long time If they are not required all the time . Better dynamically load them whenever they are needed instead of keeping them active in memory for a very long time.
6. Avoid static references If not required. These stay in the memory till class is finally unloaded Thus keep control of lot of memory space Which might not be required all the time. Program your program intelligently.
7. Tools like ZYourKit ,Jmemter,verbos GC log,JMX monitoring,Jconsole are very good to analyze the culprit responsible for out of memory occurrence .
8.Monitor the memory usage with load factor and time factor . If memory consumption is increasing due to increase in load ,it is not memory leakage problem Instead it is memory requirement by increased load . If memory consumption is increasing with time on same load It is surely memory leak and here you definitely need to resolve it otherwise later all memory will be consumed ans System will throw OutOfMemory error.
9. jmap in jdk 1.6 is excellent tool to analyze heap dump. Heap dump gives a very clear picture of objects and dependencies circulated in the memory
10. Setting FISHEYE_OPTS to right value is important .
FISHEYE_OPTS="-Xms128m -Xmx1024m -XX:MaxPermSize=256m" -- Java Heap space problem
FISHEYE_OPTS="-Xms128m -Xmx512m -XX:MaxPermSize=256m" --- Perm Generation space issue
FISHEYE_OPTS="-Xms128m -Xmx1024m -XX:MaxPermSize=256m -Xss512k" -- new thread creation space issue
No comments:
Post a Comment