jvm-08.jvm调优工具Arthas[通俗易懂]

jvm-08.jvm调优工具Arthas[通俗易懂]jvm调优工具Arthas阿尔萨斯官方文档https://arthas.aliyun.com/doc/下载curl-Ohttps://arthas.aliyun.com/arthas-boot.jar启动java-jararthas-boot.jarFullGC_Problem01是我们刚启动的java进程importjava.math.BigDecimal;importjava.util.ArrayList;importjava.util.Date;import

大家好,又见面了,我是你们的朋友全栈君。

jvm调优工具Arthas阿尔萨斯

官方文档
https://arthas.aliyun.com/doc/

下载

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

在这里插入图片描述

启动

java -jar arthas-boot.jar

FullGC_Problem01是我们刚启动的java进程

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class FullGC_Problem01 { 
   

	private static class CardInfo { 
   
		BigDecimal price = new BigDecimal(0.0);
		String name = "张三";
		int age = 5;
		Date birthdate = new Date();

		public void m() { 
   }
	}

	private static ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(50,
			new ThreadPoolExecutor.DiscardOldestPolicy());

	public static void main(String[] args) throws Exception { 
   
		executor.setMaximumPoolSize(50);

		for (;;) { 
   
			modelFit();
			Thread.sleep(100);
		}
	}

	private static void modelFit() { 
   
		List<CardInfo> taskList = getAllCardInfo();
		taskList.forEach(info -> { 
   
			// do something
			executor.scheduleWithFixedDelay(() -> { 
   
				// do sth with info
				info.m();

			}, 2, 3, TimeUnit.SECONDS);
		});
	}

	private static List<CardInfo> getAllCardInfo() { 
   
		List<CardInfo> taskList = new ArrayList<>();

		for (int i = 0; i < 100; i++) { 
   
			CardInfo ci = new CardInfo();
			taskList.add(ci);
		}

		return taskList;
	}

}

在这里插入图片描述

监控

输入1回车,将arthas挂上去

开始对FullGC_Problem1进程进行监控
在这里插入图片描述

dashboard

它会不断刷新

线程信息、内存信息、运行时环境
在这里插入图片描述

查看是否有线程死锁

thread -b

在这里插入图片描述

追踪方法的执行链路

trace FullGC_Problem01 modelFit

在这里插入图片描述

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/138301.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号