linux下oom排查 Arthas

package com.lm.demo.arthas.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping("/test")
public class TestController {
    @GetMapping("/test")
    public String test() throws InterruptedException {
        tst ();
        return "ok";
    }

    void tst () throws InterruptedException {
        long i =0;
        ArrayList<HeapTest>  heapTests = new ArrayList<>();
        while (true){
            heapTests.add(new HeapTest());
            Thread.sleep(100);
            System.out.println(++i);
        }
    }
}


下载运行Arthas

在命令行下面执行(使用和目标进程一致的用户启动,否则可能 attach 失败):

curl -O https://arthas.aliyun.com/arthas-boot.jar
java -jar arthas-boot.jar

很明显,因为方法不可能执行完,它的局部变量heapTests是不会释放的,但又在不停的new,它后面的一个个的new肯定也不会释放,最后肯定会OOM。

用dashbaord就可以看到大致在哪一行代码有问题

相关推荐

  1. OutOfMemoryError异常OOM排查

    2023-12-20 20:24:03       24 阅读
  2. 使用arthas排查请求超时问题

    2023-12-20 20:24:03       55 阅读
  3. CPU飙升和OOM排查思路

    2023-12-20 20:24:03       40 阅读
  4. 浅谈LinuxOOM Killer机制

    2023-12-20 20:24:03       57 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-20 20:24:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-20 20:24:03       106 阅读
  3. 在Django里面运行非项目文件

    2023-12-20 20:24:03       87 阅读
  4. Python语言-面向对象

    2023-12-20 20:24:03       96 阅读

热门阅读

  1. 2.Redis10大数据类型

    2023-12-20 20:24:03       43 阅读
  2. tmux+conda环境配置不对问题解决

    2023-12-20 20:24:03       65 阅读
  3. 从给定的数值范围创建数组 - Python

    2023-12-20 20:24:03       56 阅读
  4. Flink系列之:Print SQL连接器

    2023-12-20 20:24:03       53 阅读
  5. 计算机入门了解

    2023-12-20 20:24:03       62 阅读
  6. 【重点!】【二分查找】33.搜索旋转排序数组

    2023-12-20 20:24:03       67 阅读