---
title: "JEE - Unveiling Java OOM (Out of Memory Error)"
author: "vanghoh"
date: "2012-02-03T15:03:14Z"
tags: []
categories: ["非技术"]
slug: "jee-unveiling-java-oom-out-of-memory-error"
draft: false
lastmod: "2012-02-03T16:16:39Z"
id: 1392205
url: "https://vanghoh.iteye.com/blog/1392205"
---

**java.lang.OutOfMemoryError: Perm Space** 

Only Oracle(Sun) HotSpot JVM has perm space.

 

**java.lang.OutOfMemoryError: Java heap space**   
**java.lang.OutOfMemoryError: unable to create new native thread**   
**java.lang.OutOfMemoryError: requested xxxx bytes for Chunk::new. Out of swap space** 

**java.lang.OutOfMemoryError: GC overhead limit exceeded**

 

It’s an alert from JVM and this generally means the GC spends excessive amount of time – by default, 98% of the total CPU time spent for the process – and is able to recover very little memory – less than 2% of the heap.

**What to do to resolve this exception?**

If you’re executing your own code, you’ve got a tough job at hand – to review your code.

> 1. You’re probably creating lots of temporary objects in a loop; See if created object(s) can be reused.  
> 2. If it’s a genuine requirement, try increasing the max heap size (XmX) in JVM arguments.

**I don’t want JVM to throw this alert. Can I disable it?**  
You can turn this off with the command line option *-XX:-UseGCOverheadLimit*

More on this here: [http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html#par\_gc.oom](http://gougou.fqdaili.com/baidu.com.php?u=6a476780fabddf06841Oi8vd3d3Lm9yYWNsZS5jb20vdGVjaG5ldHdvcmsvamF2YS9qYXZhc2UvZ2MtdHVuaW5nLTYtMTQwNTIzLmh0bQ%3D%3D&b=15#par_gc.oom)

**java.lang.OutOfMemoryError: bitmap size exeeds VM budget**