@Data
public class Customer {
private int no;
private String username;
private BigDecimal money;
private byte[] a = new byte[1024 * 1024]; // 这里1024*1024byte等于1m
}
public class MyTestOOM {
public static void main(String[] args) {
List<Customer> customerList = new ArrayList<>();
while (true) {
Customer customer = new Customer();
customer.setNo(1);
customer.setUsername("testOOM");
customer.setMoney(new BigDecimal("1000"));
customerList.add(customer);
System.out.println(customerList.size());
}
}
}