一、准备工作
准备一个工程jvm-full-gc,核心代码:
@RestControllerpublic class IndexController {@RequestMapping("/user/process")public String processUserData() throws InterruptedException {ArrayList<User> users = queryUsers();for (User user: users) {System.out.println("user:" + user.toString());}return "end";}/*** 模拟批量查询用户场景* @return*/private ArrayList<User> queryUsers() {ArrayList<User> users = new ArrayList<>();for (int i = 0; i < 5000; i++) {users.add(new User(i,"Andy"));}return users;}}