We are using a java application which is based on RMI.When we run the application the memory usage keep on increasing even though the the application is ideal stage.We are mainly using Vector and hash map data structure.how to minimize the java memory usage/repair memory leakage?
Thanks in advance
-
You need to do some root cause analysis of where your memory leak is coming from. What JDK are you using?Martijn Verburg– Martijn Verburg2010年12月08日 11:52:43 +00:00Commented Dec 8, 2010 at 11:52
-
Try take memory snapshots with JProfiler (or any other memory profiler) and compare them. You'll clearly see where memory is going.Petro Semeniuk– Petro Semeniuk2010年12月08日 12:11:40 +00:00Commented Dec 8, 2010 at 12:11
-
I am using j2sdk1.4.2_18Selva– Selva2010年12月08日 12:12:14 +00:00Commented Dec 8, 2010 at 12:12
-
1How are you measuring memory usage? Are you looking at the process (through tools such as ps or the Windows Task Manager), or are you looking at Java heap usage?Dan Breslau– Dan Breslau2010年12月08日 12:19:40 +00:00Commented Dec 8, 2010 at 12:19
-
Using Windows Task Manager,is it right way?how to view the java heap usage?Selva– Selva2010年12月08日 12:22:36 +00:00Commented Dec 8, 2010 at 12:22
3 Answers 3
If you can't upgrade your JDK version, I suggest testing your application on another machine (real or virtual) with the latest 1.6 JDK, and then use the built in jvisualvm which is a really great tool for diagnosing problems like this.
Comments
I'd start with trying to understand Java's memory model.
Here's a stackoverflow question (858250) with lots of links explaining.
Comments
Since you're using 1.4.2, and you can't use jmap or visualvm, I'd suggest running your Java process with:
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="foo.out"
and after it runs out of memory, open foo.out with HPjmeter. This should help you identify the objects ballooning in your application.