I am developing a java web application and I am running it on a Tomcat 7 server.
I am checking the size of the memory by calling:
System.out.println("Total memory is: " + Runtime.getRuntime().totalMemory());
What I am noticing that the size is changing, when the size of my data getting larger the Runtime.getRuntime().totalMemory() get larger as well.
1- Is the JVM trying to be larger than the size of the application data?
2- Is there any limit for the JVM size, other than the RAM memory size?
3- A third question not very related to the two above: what is the size of a running Tomcat 7 server application? Actually I have a small RAM in my server (Amazon cloud server, free tire, 600 MB RAM), And I am noticing that JAVA occupies about 52% of the memory without deploying any web application.
Excuse me for my very basic questions, I am not familiar with web servers and web applications.
Yes, the limit set by you.
-Xmxfor maximum heap size and-Xmsfor initial heap sizeThe JVM runs virtually. If you allocate more memory than available on your machine it will be swapped out.
Haven’t you answered that question yourself? It’s 52% of your memory. In general you can specify for your Tomcat the memory max. and min. size as well. After all it’s just another JVM.