7.12.07

Java Virtual Machine (JVM) - JVM virtual memory footprint

In the 64-bit 1.4.2 and 5.0 jvm's (the ones prior to the current Java SE 6, aka mustang,
drops on java.net), the default maximum size of the generated code cache (it contains
the interpreter and code generated by the compilers) is 1 gigabyte. At startup, the jvm
attempts to reserve that amount of virtual address space for the code cache. Note that this
is a 'reservation' as opposed to a 'commitment'. Only 1 megabyte of physical memory
and corresponding swap space is actually allocated during jvm initialization.

We did this because reserved, but uncommitted, virtual address space is basically 'free'
when running a 64-bit jvm under a 64-bit operating system. But we realized during
mustang development that scenarios such as you describe were possible and reduced
the default maximum code cache size to 48 mb in the 64-bit vm's. We also raised the
initial committed size to around 2.5 mb. We're in the process of backporting that change
to 1.4.2 and 5.0.

In the meantime, you can override the default using the ReservedCodeCacheSize switch, e.g.,

-XX:ReservedCodeCacheSize=48m

which will reserve the mustang default.

Thanks for pointing out the problem.

Paul

Hi,
I was wondering why java processes (even the simplest
ones) would take up Gigabytes of virtual memory on an
AMD64 machine? If I ulimit virtual memory usage to
1GB I get:
8<
Error occurred during initialization of VM
Could not reserve enough space for code cache
8<
even for a simple "java -version". The JDK I'm using
is
Java(TM) 2 Runtime Environment, Standard Edition
(build 1.5.0_04-b05)
Java HotSpot(TM) 64-Bit Server VM (build
1.5.0_04-b05, mixed mode)
I'm running Red Hat Enterprise Linux AS 4.0 on a dual
Xeon box with 2GB.

Cheers, Alex

No comments: