JVM 调优 —— OutOfMemory
2016-03-11 11:34
106 查看
零. 简介
OutOfMemory 意思就是需要申请更大的内存, 但是内存限制无法申请到需要的内存。
一. 解决方法
基本上解决方向有两种:
检查程序是否有问题, 是不是写死循环不停地创建并持有对象导致内存不足
内存确实不够, 分为老年代内存不足和永久代内存不足
(1) 老年代内存不足
看一段 GC 日志:在 Full GC 结束后, 但是老年代占用空间还是接近或者等于老年代最大空间, 说明老年代空间确实分配不够。 调大 -Xms、 -Xmx 并保持新生代大小不变,直到 GC 日志不出现关键字 Exception in thread “main” java.lang.OutOfMemoryError: Java heap space。
(2) 永久代内存不足
看一段 GC 日志:在 Full GC 结束后, 但是永久代占用空间还是接近或者等于永久代最大空间, 说明永久代空间确实分配不够。 调大 -XX:PermSize、 -XX:MaxPermSize,直到 GC 日志不出现关键字 Exception in thread “main” java.lang.OutOfMemoryError: PermGen space。
OutOfMemory 意思就是需要申请更大的内存, 但是内存限制无法申请到需要的内存。
一. 解决方法
基本上解决方向有两种:
检查程序是否有问题, 是不是写死循环不停地创建并持有对象导致内存不足
内存确实不够, 分为老年代内存不足和永久代内存不足
(1) 老年代内存不足
看一段 GC 日志:在 Full GC 结束后, 但是老年代占用空间还是接近或者等于老年代最大空间, 说明老年代空间确实分配不够。 调大 -Xms、 -Xmx 并保持新生代大小不变,直到 GC 日志不出现关键字 Exception in thread “main” java.lang.OutOfMemoryError: Java heap space。
2016-01-19T14:18:19.883+0800: 179.163: [CMS-concurrent-reset-start] 2016-01-19T14:18:19.893+0800: 179.173: [CMS-concurrent-reset: 0.009/0.009 secs] [Times: user=0.02 sys=0.00, real=0.01 secs] {Heap before GC invocations=154 (full 1): par new generation total 943744K, used 850746K [0x0000000757000000, 0x0000000797000000, 0x0000000797000000) eden space 838912K, 100% used [0x0000000757000000, 0x000000078a340000, 0x000000078a340000) from space 104832K, 11% used [0x000000078a340000, 0x000000078aecea30, 0x00000007909a0000) to space 104832K, 0% used [0x00000007909a0000, 0x00000007909a0000, 0x0000000797000000) concurrent mark-sweep generation total 1560576K, used 1560576K [0x0000000797000000, 0x00000007f6400000, 0x00000007f6400000) concurrent-mark-sweep perm gen total 159744K, used 69030K [0x00000007f6400000, 0x0000000800000000, 0x0000000800000000)
(2) 永久代内存不足
看一段 GC 日志:在 Full GC 结束后, 但是永久代占用空间还是接近或者等于永久代最大空间, 说明永久代空间确实分配不够。 调大 -XX:PermSize、 -XX:MaxPermSize,直到 GC 日志不出现关键字 Exception in thread “main” java.lang.OutOfMemoryError: PermGen space。
2016-01-19T14:18:19.883+0800: 179.163: [CMS-concurrent-reset-start] 2016-01-19T14:18:19.893+0800: 179.173: [CMS-concurrent-reset: 0.009/0.009 secs] [Times: user=0.02 sys=0.00, real=0.01 secs] {Heap before GC invocations=154 (full 1): par new generation total 943744K, used 850746K [0x0000000757000000, 0x0000000797000000, 0x0000000797000000) eden space 838912K, 100% used [0x0000000757000000, 0x000000078a340000, 0x000000078a340000) from space 104832K, 11% used [0x000000078a340000, 0x000000078aecea30, 0x00000007909a0000) to space 104832K, 0% used [0x00000007909a0000, 0x00000007909a0000, 0x0000000797000000) concurrent mark-sweep generation total 1560576K, used 345246K [0x0000000797000000, 0x00000007f6400000, 0x00000007f6400000) concurrent-mark-sweep perm gen total 159744K, used 159744K [0x00000007f6400000, 0x0000000800000000, 0x0000000800000000)
相关文章推荐
- [转]Stop Sharing Session State between Multiple Tabs of Browser
- 多线程
- Kmean算法
- JQuery的change无效
- JAVA排序算法---快速排序
- JAVA排序算法---快速排序
- JAVA排序算法---快速排序
- JAVA排序算法---快速排序
- JAVA排序算法---快速排序
- JAVA排序算法---快速排序
- JAVA排序算法---快速排序
- JAVA排序算法---快速排序
- XAMPP的安装及配置
- androidUSB通信——打印机
- androidUSB通信——打印机
- HEVC标准中的图像分割(2)
- Web Api 与 Andriod 接口对接开发经验
- listView自动滑动功能
- 数据存储之(一):iOS数据存储方式及沙盒的说明
- 归并排序详解