Home

Xmx512m

Xmx512m refers to a Java Virtual Machine (JVM) option that sets the maximum size of the Java heap to 512 megabytes. The Java heap is the area of memory used for object allocation and garbage collection. The suffix m indicates megabytes, with 1 m equal to 1024*1024 bytes. Common alternatives include k for kilobytes and g for gigabytes, and these suffixes are generally case-insensitive.

Usage and implications. The option is provided to the JVM at startup, for example: java -Xmx512m -jar

Considerations for tuning. A larger heap reduces the frequency of garbage collection but can increase pause

Relation to other memory areas. -Xmx specifically controls the Java heap. Other memory spaces used by the

myapp.jar.
It
is
often
paired
with
-Xms
to
fix
the
initial
heap
size
(for
example,
-Xms512m).
The
Oracle/OpenJDK
JVM
will
attempt
to
allocate
the
specified
heap
at
launch
and
will
not
grow
beyond
this
limit.
Actual
availability
can
be
affected
by
the
operating
system,
hardware,
other
processes,
and,
in
containerized
environments,
restrictions
imposed
by
cgroups.
times
when
GC
does
occur,
while
a
smaller
heap
may
lead
to
more
frequent
collection
and
potential
pauses.
Setting
-Xms
close
to
-Xmx
can
reduce
heap
expansion
overhead.
Availability
of
512
MB
may
also
be
limited
on
32-bit
JVMs
or
systems
with
tight
address
space,
and
on
modern
containers,
memory
limits
can
influence
the
effective
heap
size.
JVM,
such
as
the
metaspace
(or
permanent
generation
in
older
versions)
and
native
memory,
are
not
directly
constrained
by
-Xmx.