kjkoster
18-07-2008, 07:21
Dear All,
Remember when you first opened a command line on a machine with a full gigabyte of RAM? Whoa, sooo much memory. We were talking about ditching swap space in those days. :-) Of course, today multi-gigabyte RAM systems are being sold to grandmothers for surfing and e-mail.
The older versions of Java had a default memory limit of 64MB, which is not a whole lot. I almost always use jconsole to find the typical memory usage of my application and then use the -Xmx command line option (http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp) to give it the memory it needs, plus a reasonable margin. Sometimes I even go in and tune the individual memory pools (scroll down to memory pools) (http://www.kjkoster.org/zapcat/Zabbix_Java_Template.html).
I've always wondered: is it possible to give a JVM too much memory? Imagine I have several gigabytes of memory in a box that does nothing but host a Tomcat instance on a single vm. Why would I not assign 2GB of memory to the JVM?
For development machines I prefer to keep memory tight, so that I get alerted to memory leaks early in the game. But for production machines I don't know.
I have some second-hand anecdotes that claim that too much memory causes longer garbage collector pauses, but that was in the Java 1.3.1 days. How is that for Java 1.5 and Java 1.6? Was it even true for those older VM's?
What is your experience?
Kees Jan
PS. Oh, and as you storm in with an answer, please remember to provide some reliable sources and figures (http://xkcd.com/285/). ;-)
Remember when you first opened a command line on a machine with a full gigabyte of RAM? Whoa, sooo much memory. We were talking about ditching swap space in those days. :-) Of course, today multi-gigabyte RAM systems are being sold to grandmothers for surfing and e-mail.
The older versions of Java had a default memory limit of 64MB, which is not a whole lot. I almost always use jconsole to find the typical memory usage of my application and then use the -Xmx command line option (http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp) to give it the memory it needs, plus a reasonable margin. Sometimes I even go in and tune the individual memory pools (scroll down to memory pools) (http://www.kjkoster.org/zapcat/Zabbix_Java_Template.html).
I've always wondered: is it possible to give a JVM too much memory? Imagine I have several gigabytes of memory in a box that does nothing but host a Tomcat instance on a single vm. Why would I not assign 2GB of memory to the JVM?
For development machines I prefer to keep memory tight, so that I get alerted to memory leaks early in the game. But for production machines I don't know.
I have some second-hand anecdotes that claim that too much memory causes longer garbage collector pauses, but that was in the Java 1.3.1 days. How is that for Java 1.5 and Java 1.6? Was it even true for those older VM's?
What is your experience?
Kees Jan
PS. Oh, and as you storm in with an answer, please remember to provide some reliable sources and figures (http://xkcd.com/285/). ;-)