##java大对象类
public class MiBigObject {
private String f1;
private String f2;
private String f3;
private String f4;
private String f5;
private String f6;
private String f7;
private String f8;
private String f9;
private String f10;
private String f11;
private String f12;
private String f13;
private String f14;
private String f15;
private String f16;
private String f17;
private String f18;
private String f19;
private String f20;
private Integer i21;
private Integer i22;
private Integer i23;
private Integer i24;
private Integer i25;
private Integer i26;
private Integer i27;
private Integer i28;
private Integer i29;
private Integer i30;
private Integer i31;
private Integer i32;
private Integer i33;
private Integer i34;
private Integer i35;
private Integer i36;
private Integer i37;
private Integer i38;
private Integer i39;
private Integer i40;
private Long l41;
private Long l42;
private Long l43;
private Long l44;
private Long l45;
private Long l46;
private Long l47;
private Long l48;
private Long l49;
private Long l50;
public String getF1() {
return f1;
}
public void setF1(String f1) {
this.f1 = f1;
}
public String getF2() {
return f2;
}
public void setF2(String f2) {
this.f2 = f2;
}
public String getF3() {
return f3;
}
public void setF3(String f3) {
this.f3 = f3;
}
public String getF4() {
return f4;
}
public void setF4(String f4) {
this.f4 = f4;
}
public String getF5() {
return f5;
}
public void setF5(String f5) {
this.f5 = f5;
}
public String getF6() {
return f6;
}
public void setF6(String f6) {
this.f6 = f6;
}
public String getF7() {
return f7;
}
public void setF7(String f7) {
this.f7 = f7;
}
public String getF8() {
return f8;
}
public void setF8(String f8) {
this.f8 = f8;
}
public String getF9() {
return f9;
}
public void setF9(String f9) {
this.f9 = f9;
}
public String getF10() {
return f10;
}
public void setF10(String f10) {
this.f10 = f10;
}
public String getF11() {
return f11;
}
public void setF11(String f11) {
this.f11 = f11;
}
public String getF12() {
return f12;
}
public void setF12(String f12) {
this.f12 = f12;
}
public String getF13() {
return f13;
}
public void setF13(String f13) {
this.f13 = f13;
}
public String getF14() {
return f14;
}
public void setF14(String f14) {
this.f14 = f14;
}
public String getF15() {
return f15;
}
public void setF15(String f15) {
this.f15 = f15;
}
public String getF16() {
return f16;
}
public void setF16(String f16) {
this.f16 = f16;
}
public String getF17() {
return f17;
}
public void setF17(String f17) {
this.f17 = f17;
}
public String getF18() {
return f18;
}
public void setF18(String f18) {
this.f18 = f18;
}
public String getF19() {
return f19;
}
public void setF19(String f19) {
this.f19 = f19;
}
public String getF20() {
return f20;
}
public void setF20(String f20) {
this.f20 = f20;
}
public Integer getI21() {
return i21;
}
public void setI21(Integer i21) {
this.i21 = i21;
}
public Integer getI22() {
return i22;
}
public void setI22(Integer i22) {
this.i22 = i22;
}
public Integer getI23() {
return i23;
}
public void setI23(Integer i23) {
this.i23 = i23;
}
public Integer getI24() {
return i24;
}
public void setI24(Integer i24) {
this.i24 = i24;
}
public Integer getI25() {
return i25;
}
public void setI25(Integer i25) {
this.i25 = i25;
}
public Integer getI26() {
return i26;
}
public void setI26(Integer i26) {
this.i26 = i26;
}
public Integer getI27() {
return i27;
}
public void setI27(Integer i27) {
this.i27 = i27;
}
public Integer getI28() {
return i28;
}
public void setI28(Integer i28) {
this.i28 = i28;
}
public Integer getI29() {
return i29;
}
public void setI29(Integer i29) {
this.i29 = i29;
}
public Integer getI30() {
return i30;
}
public void setI30(Integer i30) {
this.i30 = i30;
}
public Integer getI31() {
return i31;
}
public void setI31(Integer i31) {
this.i31 = i31;
}
public Integer getI32() {
return i32;
}
public void setI32(Integer i32) {
this.i32 = i32;
}
public Integer getI33() {
return i33;
}
public void setI33(Integer i33) {
this.i33 = i33;
}
public Integer getI34() {
return i34;
}
public void setI34(Integer i34) {
this.i34 = i34;
}
public Integer getI35() {
return i35;
}
public void setI35(Integer i35) {
this.i35 = i35;
}
public Integer getI36() {
return i36;
}
public void setI36(Integer i36) {
this.i36 = i36;
}
public Integer getI37() {
return i37;
}
public void setI37(Integer i37) {
this.i37 = i37;
}
public Integer getI38() {
return i38;
}
public void setI38(Integer i38) {
this.i38 = i38;
}
public Integer getI39() {
return i39;
}
public void setI39(Integer i39) {
this.i39 = i39;
}
public Integer getI40() {
return i40;
}
public void setI40(Integer i40) {
this.i40 = i40;
}
public Long getL41() {
return l41;
}
public void setL41(Long l41) {
this.l41 = l41;
}
public Long getL42() {
return l42;
}
public void setL42(Long l42) {
this.l42 = l42;
}
public Long getL43() {
return l43;
}
public void setL43(Long l43) {
this.l43 = l43;
}
public Long getL44() {
return l44;
}
public void setL44(Long l44) {
this.l44 = l44;
}
public Long getL45() {
return l45;
}
public void setL45(Long l45) {
this.l45 = l45;
}
public Long getL46() {
return l46;
}
public void setL46(Long l46) {
this.l46 = l46;
}
public Long getL47() {
return l47;
}
public void setL47(Long l47) {
this.l47 = l47;
}
public Long getL48() {
return l48;
}
public void setL48(Long l48) {
this.l48 = l48;
}
public Long getL49() {
return l49;
}
public void setL49(Long l49) {
this.l49 = l49;
}
public Long getL50() {
return l50;
}
public void setL50(Long l50) {
this.l50 = l50;
}
}
##内存溢出测试代码
import java.util.ArrayList;
import java.util.List;
public class OutOfMemoryTest {
public static void main(String[] args) {
List<MiBigObject> miBigObjects = new ArrayList<>();
while(true) {
MiBigObject miBigObject = new MiBigObject();
miBigObject.setF1("t1");
miBigObject.setF2("t2");
miBigObject.setF3("t3");
miBigObject.setF4("t4");
miBigObject.setF5("t5");
miBigObject.setF6("t6");
miBigObject.setF7("t7");
miBigObject.setF8("t8");
miBigObject.setF9("t9");
miBigObject.setF10("t10");
miBigObject.setF11("t11");
miBigObject.setF12("t12");
miBigObject.setF13("t13");
miBigObject.setF14("t14");
miBigObject.setF15("t15");
miBigObject.setF16("t16");
miBigObject.setF17("t17");
miBigObject.setF18("t18");
miBigObject.setF19("t19");
miBigObject.setF20("t20");
miBigObject.setI21(1);
miBigObject.setI22(2);
miBigObject.setI23(3);
miBigObject.setI24(4);
miBigObject.setI25(5);
miBigObject.setI26(6);
miBigObject.setI27(7);
miBigObject.setI28(8);
miBigObject.setI29(9);
miBigObject.setI30(10);
miBigObject.setI31(11);
miBigObject.setI32(12);
miBigObject.setI33(13);
miBigObject.setI34(14);
miBigObject.setI35(15);
miBigObject.setI36(16);
miBigObject.setI37(17);
miBigObject.setI38(18);
miBigObject.setI39(19);
miBigObject.setI40(20);
miBigObject.setL41(21L);
miBigObject.setL42(22L);
miBigObject.setL43(23L);
miBigObject.setL44(24L);
miBigObject.setL45(25L);
miBigObject.setL46(26L);
miBigObject.setL47(27L);
miBigObject.setL48(28L);
miBigObject.setL49(29L);
miBigObject.setL50(30L);
miBigObjects.add(miBigObject);
}
}
}
##gdb调试内存溢出堆栈
#0 MemAllocator::Allocation::check_out_of_memory (this=0x7ffff7bfe660) at /home/yym/openjdk17/jdk17-master/src/hotspot/share/gc/shared/memAllocator.cpp:126
#1 0x00007ffff677afee in MemAllocator::Allocation::~Allocation (this=0x7ffff7bfe660, __in_chrg=<optimized out>)
at /home/yym/openjdk17/jdk17-master/src/hotspot/share/gc/shared/memAllocator.cpp:84
#2 0x00007ffff677a0ab in MemAllocator::allocate (this=0x7ffff7bfe6d0) at /home/yym/openjdk17/jdk17-master/src/hotspot/share/gc/shared/memAllocator.cpp:373
#3 0x00007ffff6351067 in CollectedHeap::obj_allocate (this=0x7ffff00453d0, klass=0x1000c1000, size=27, __the_thread__=0x7ffff0028920)
at /home/yym/openjdk17/jdk17-master/src/hotspot/share/gc/shared/collectedHeap.inline.hpp:36
#4 0x00007ffff6344c81 in InstanceKlass::allocate_instance (this=0x1000c1000, __the_thread__=0x7ffff0028920)
at /home/yym/openjdk17/jdk17-master/src/hotspot/share/oops/instanceKlass.cpp:1375
#5 0x00007ffff69579f7 in OptoRuntime::new_instance_C (klass=0x1000c1000, current=0x7ffff0028920) at /home/yym/openjdk17/jdk17-master/src/hotspot/share/opto/runtime.cpp:219
#6 0x00007fffe1082145 in ?? ()
#7 0x00000000fdd65108 in ?? ()
#8 0x00007fffe8bdba68 in ?? ()
#9 0x00007fffd9c0e800 in ?? ()
#10 0x00007fffd9c16138 in ?? ()
#11 0x00000000fdd758d8 in ?? ()
#12 0x00007fffd9c0fc50 in ?? ()
#13 0x0000000000000000 in ?? ()
##
#0 MemAllocator::Allocation::check_out_of_memory (this=0x7ffff7bfe180) at /home/yym/openjdk17/jdk17-master/src/hotspot/share/gc/shared/memAllocator.cpp:126
#1 0x00007ffff677afee in MemAllocator::Allocation::~Allocation (this=0x7ffff7bfe180, __in_chrg=<optimized out>)
at /home/yym/openjdk17/jdk17-master/src/hotspot/share/gc/shared/memAllocator.cpp:84
#2 0x00007ffff677a0ab in MemAllocator::allocate (this=0x7ffff7bfe1f0) at /home/yym/openjdk17/jdk17-master/src/hotspot/share/gc/shared/memAllocator.cpp:373
#3 0x00007ffff6351067 in CollectedHeap::obj_allocate (this=0x7ffff00453d0, klass=0x1000c1000, size=27, __the_thread__=0x7ffff0028920)
at /home/yym/openjdk17/jdk17-master/src/hotspot/share/gc/shared/collectedHeap.inline.hpp:36
#4 0x00007ffff6344c81 in InstanceKlass::allocate_instance (this=0x1000c1000, __the_thread__=0x7ffff0028920)
at /home/yym/openjdk17/jdk17-master/src/hotspot/share/oops/instanceKlass.cpp:1375
#5 0x00007ffff5eda4f4 in Runtime1::new_instance (current=0x7ffff0028920, klass=0x1000c1000) at /home/yym/openjdk17/jdk17-master/src/hotspot/share/c1/c1_Runtime1.cpp:360
#6 0x00007fffe1085ba7 in ?? ()
#7 0x00007ffff7bfe300 in ?? ()
#8 0x0000000000000000 in ?? ()
##check_out_of_memory()方法源码 传送门