zoukankan      html  css  js  c++  java
  • JVM 调优 —— OutOfMemory

    零. 简单介绍
    OutOfMemory 意思就是须要申请更大的内存, 可是内存限制无法申请到须要的内存。

     



    一. 解决方法
    基本上解决方向有两种:

    1. 检查程序是否有问题。 是不是写死循环不停地创建并持有对象导致内存不足

    1. 内存确实不够, 分为老年代内存不足和永久代内存不足

    (1) 老年代内存不足

    看一段 GC 日志:在 Full GC 结束后, 可是老年代占用空间还是接近或者等于老年代最大空间, 说明老年代空间确实分配不够。 调大 -Xms、 -Xmx 并保持新生代大小不变。直到 GC 日志不出现keyword 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 日志不出现keyword 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)




  • 相关阅读:
    【Redis】简介与安装
    【JAVA】 Java 连接池的工作原理
    【异常】ORA-01536: space quota exceeded for tablespace
    【Oracle】Oracle 序列步长问题
    【ORACLE】常用脚本
    【ORACLE】特殊的NULL
    【JAVA】Runtime
    【JAVA】Calendar
    出现脚本错误或者未正确调用 Page()
    小程序出现 “2 not found” 解决方案
  • 原文地址:https://www.cnblogs.com/llguanli/p/7306955.html
Copyright © 2011-2022 走看看