26.7–工具–jconsole
1、工具位置
![*](https://cloud.cxykk.com/images/2024/1/27/1327/1706333256484.png)
2、测试
2.1、代码
package com.fei.zhou.day1;
import java.util.ArrayList;
import java.util.List;
public class JConSoleTest {
JConSoleTest() {
// 创建构造对象都要分配128Kb的内存给数组
// bis局部变量,垃圾回收会定时回收
byte[] bis = new byte[128 * 1024];
}
public static void main(String[] args) throws Exception {
Thread.sleep(10000);// 10秒方便我们打开监控器
addMemory();
}
/**
*
* @Description:增加内存
* @author feiZhou
* @throws InterruptedException
* @date 2018年11月18日上午7:57:01
*/
private static void addMemory() throws Exception {
// 描述:
int size = 1000;
List<JConSoleTest> list = new ArrayList<>();
for (int i = 0; i < size; i++) {
Thread.sleep(100);// 每0.1秒增加一次内存
list.add(new JConSoleTest());
}
}
}
2.2、结果
![*](https://cloud.cxykk.com/images/2024/1/27/1327/1706333262309.png)
![*](https://cloud.cxykk.com/images/2024/1/27/1327/1706333268002.png)
![*](https://cloud.cxykk.com/images/2024/1/27/1327/1706333273870.png)
![*](https://cloud.cxykk.com/images/2024/1/27/1327/1706333279625.png)