I have a program where the main program runs a TimerTask every 10 sec. I have observed that the memory usage when running the commands " top" and "ps -aux" on the Linux box slowly increases. Over the time span of 3 hours Linux reports that the java process has grown approx 30kb. I have started the java process with the options -Xmx32M and -Xms32M (as it is running on a small hardware platfrom) and I can see that by using the Runtime.getRuntime() the jvm's memory usage looks fine:
Total : 33357824 Max : 33357824 Free : 24832448 Used : 8525376
When looking at the top command following is displayed: PID USER STATUS RSS PPID %CPU %MEM COMMAND1544 root S 38180 1 0.0 32.2 java
And the ps command:1544 root 38180 S java -Xmx32m -Xms32m main
There are a couple of things that I don't understand:
- Why the Java process seems to increase in memory usage and it doesn't ever decrease again. The program needs to run 24/7 and I'm not sure if it will do this at the moment. Could this have something to do with Java program or could it be related to the JVM. I have tried it with Java 1.5 and Java 1.6 on Debain and another Linux distro with the same result.
- Why Linux reports the java process uses 38180kb, when I have limited the java heap to 32Mb.
- Why it increaes the memory when Java clealy have enough, is this maybe related to os resoures like files, sockets, etc?
Any Help would be greatly appriciated.