This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hello guys! I have a problem with java. I have a Linux Redhat 8.0 dual processor machine with 2.5Gb. I start my Tomcat 4.1.27 with JVM 1.4.2 using JAVA_OPTS -server -Xms512m -Xmx1024m. Then I look memory usage with top command and a see this:
5730 beta48 25 0 195M 195M 11972 S 1.6 7.7 2:52 java I can't understand two things: 1) why java allocate only 195M rather than 512M 2) why java reach only 256M of allocation under heavy load of processing and not 1024M Thanks in advence. Regards. Fabry.
I can't understand two things: 1) why java allocate only 195M rather than 512M 2) why java reach only 256M of allocation under heavy load of processing and not 1024M
The JVM only allocates the memory it needs. It would negatively impact the startup time for it to spend time allocating more memory than it needs, not to mention that once a JVM allocates memory it will not release it back to the system, so it is a Good Thing that the JVM only allocates the memory it requires. Be aware that the -Xms and -Xmx flags only dictate heap size, so it is not uncommon for the size of a JVM to exceed these values since there are things that do not occupy the heap (i.e. thread stack).
This is an ongoing discussion that I am often involved in. My personal view from profiling applications is that for overall performance setting your minimum = maximum is the way to go. The CPU delay ( we are only at java 1.3.x in production (no parallel garbage collection ) to increase the available memory when it is needed by the JVM is significant and outweighs the lost time in a full mark and sweep of the maximum JVM. This is esplecially true as even with a minimal JVM size it will eventually grow to maximum and you will still be losing the full JVM mark and sweep. If the JVM resized itself to a smaller memory footprint when applicable a minimum setting might provide some value.
Unless you have problems with pauses, try granting as much memory as possible to the virtual machine. The default size (64MB) is often too small. Setting -Xms and -Xmx to the same value increases predictability by removing the most important sizing decision from the virtual machine. On the other hand, the virtual machine can't compensate if you make a poor choice. Be sure to increase the memory as you increase the number of processors, since allocation can be parallelized.