Home

javalangOutOfMemoryError

java.lang.OutOfMemoryError is a runtime error raised by the Java Virtual Machine when it cannot allocate memory for an object or for native process operations. It signals that the JVM has exhausted memory resources and cannot continue normal execution.

The error manifests in several forms, depending on the exhausted memory region. Java heap space occurs when

Causes of an OutOfMemoryError include memory leaks, retaining large collections or objects longer than necessary, processing

Mitigation strategies focus on reducing memory pressure and adjusting JVM limits. Common steps are increasing heap

Catching OutOfMemoryError is possible but generally discouraged, since it indicates a condition that is difficult to

there
is
no
room
for
new
objects
on
the
heap.
GC
overhead
limit
exceeded
indicates
excessive
time
spent
performing
garbage
collection
without
freeing
enough
memory.
Metaspace
(or
PermGen
in
older
JVMs)
refers
to
memory
available
for
class
metadata.
Other
variants
include
unable
to
create
new
native
thread,
which
happens
when
the
operating
system
or
JVM
limits
prevent
creating
more
threads,
and
direct
buffer
memory,
which
relates
to
off-heap
memory
used
by
direct
byte
buffers.
very
large
data
sets,
and
insufficient
or
misconfigured
heap
or
metaspace
sizes.
Excessive
native
allocations
or
a
high
number
of
concurrent
threads
can
also
trigger
native
memory
exhaustion.
Diagnosis
typically
involves
monitoring
memory
usage
and
GC
behavior,
reviewing
GC
logs,
and
analyzing
heap
dumps
with
tools
such
as
VisualVM
or
Eclipse
MAT.
size
with
-Xmx,
tuning
or
changing
the
garbage
collector,
increasing
MaxMetaspaceSize,
and
addressing
memory
leaks
or
cache
growth
in
the
application.
Reducing
per-object
memory
usage
or
the
total
number
of
simultaneously
live
objects
can
help,
as
can
decreasing
thread
count
or
per-thread
stack
size
to
avoid
native
memory
exhaustion.
recover
from
reliably.
Applications
are
typically
expected
to
fail
fast
and
log
diagnostic
information
for
later
analysis.