Hi, I noticed in recent emails that Leon Kolchinsky was running Tomcat and Java requested 2GB of memory unexpectedly then died due to an out of memory exception.
Bizarrely, the same thing happened to me today with very similar symptoms. Specifically, the JVM requested 8GB of memory while hotspot was trying to compile the exact same Velocity/Foreach method as Leon's example. I'm running 64 bit JDK 1.6.0_18-b07 / Tomcat 6.0.24 / APR 1.1.19. I wanted to highlight this, (someone was talking about posting a bug report). Since it's the exact same method, I'm guessing the Velocity method triggers a bug in the hotspot compilation. Note that we've been running this configuration for 5 months and I haven't seen this previously, so it's probably rare. Excerpt from hs_err -- java.lang.OutOfMemoryError: requested 8589934608 bytes for Chunk::new. Out of swap space? Current thread (0x000000005449c800): JavaThread "CompilerThread0" daemon [_thread_in_native, id=25458, stack(0x00000000 40638000,0x0000000040739000)] Current CompileTask: C2:2532 ! org.apache.velocity.runtime.directive.Foreach.render(Lorg/apache/velocity/context/InternalContextAdapter;Ljava/io/Writer;Lorg/apache/velocity/runtime/p arser/node/Node;)Z (529 bytes) --- [r...@main ~]# uname -a Linux main 2.6.18-164.9.1.el5 #1 SMP Wed Dec 9 03:27:37 EST 2009 x86_64 x86_64 x86_64 GNU/Linux -- CATALINA_OPTS="-Djava.awt.headless=true "$CATALINA_OPTS CATALINA_OPTS="-Xmx6G "$CATALINA_OPTS CATALINA_OPTS="-Xms500M "$CATALINA_OPTS CATALINA_OPTS="-server "$CATALINA_OPTS CATALINA_OPTS="-XX:PermSize=50M -XX:MaxPermSize=100M "$CATALINA_OPTS CATALINA_OPTS="-XX:+UseParallelOldGC "$CATALINA_OPTS CATALINA_OPTS="-XX:ThreadStackSize=512 "$CATALINA_OPTS WILL