I have a problem with a Java app. Yesterday, when i deployed it to have a test run, we noticed that our machine started swapping, even though this is not a real monster app, if you know what i mean. Anyway, i checked the results of top and saw that it eats around 100mb of memory (RES in top) I tried to profile memory and check if there is a memory leak, but i couldn t find one. There was an unclosed PreparedStatement, which i fixed, but it didn t mean much. I tried setting the min and max heap size (some said that min heap size is not required), and it didn t make any difference.
这就是我现在的运行方式:
#!/bin/sh
$JAVA_HOME/bin/java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9025 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -XX:MaxPermSize=40m -Xmx32M -cp ./jarName.jar uk.co.app.App app.properties
这是top 的结果 :
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
16703 root 20 0 316m 109m 6048 S 0.0 20.8 0:14.80 java
The thing i don t understand that i configure max PermSize and max Heap size, which add up to 72mb. Which is enough, the app runs well. Why is it eating 109mb of memory still and what is eating it up? It is a 37mb difference, which is quite high ratio. (34%). I don t think this is a memory leak, because max heap size is set and there is no out of memory error, or anything.
One intertesting thing may be that i made a heap dump with VisualVM and then checked it with EclipseMAT and it said that there is a possible leak in a classloader. This is what it says:
The classloader/component "sun.misc.Launcher$AppClassLoader @ 0x87efa40" occupies 9,807,664 (64.90%) bytes. The memory is accumulated in one instance of "short[][]" loaded by "".Keywords sun.misc.Launcher$AppClassLoader @ 0x87efa40
我对此不能做很多,但可能有用。
感谢你提前帮忙
<强 > EDIT 强 >
I found this one, maybe there is nothing i can do... Tomcat memory consumption is more than heap + permgen space