解决内存溢出常用方法就是打开GC日志
{Heap before GC invocations=29 (full 14):
par new generation total 306688K, used 306687K [0x0000000080000000, 0x0000000094cc0000, 0x0000000094cc0000)
eden space 272640K, 100% used [0x0000000080000000, 0x0000000090a40000, 0x0000000090a40000)
from space 34048K, 99% used [0x0000000090a40000, 0x0000000092b7ffe0, 0x0000000092b80000)
to space 34048K, 0% used [0x0000000092b80000, 0x0000000092b80000, 0x0000000094cc0000)
concurrent mark-sweep generation total 1756416K, used 1756415K [0x0000000094cc0000, 0x0000000100000000, 0x0000000100000000)
Metaspace used 43496K, capacity 44680K, committed 45056K, reserved 1089536K
class space used 5254K, capacity 5515K, committed 5632K, reserved 1048576K
2017-09-12T21:55:02.954+0800: 239.209: [Full GC (Allocation Failure) 2017-09-12T21:55:02.954+0800: 239.209: [CMS: 1756415K->1756415K(1756416K), 5.4136680 secs] 2063103K->1971243K(2063104K), [Metaspace: 43496K->43496K(1089536K)], 5.4138690 secs] [Times: user=5.41 sys=0.00, real=5.41 secs]
Heap after GC invocations=30 (full 15):
par new generation total 306688K, used 214827K [0x0000000080000000, 0x0000000094cc0000, 0x0000000094cc0000)
eden space 272640K, 78% used [0x0000000080000000, 0x000000008d1cacb0, 0x0000000090a40000)
from space 34048K, 0% used [0x0000000090a40000, 0x0000000090a40000, 0x0000000092b80000)
to space 34048K, 0% used [0x0000000092b80000, 0x0000000092b80000, 0x0000000094cc0000)
concurrent mark-sweep generation total 1756416K, used 1756415K [0x0000000094cc0000, 0x0000000100000000, 0x0000000100000000)
Metaspace used 43238K, capacity 44256K, committed 45056K, reserved 1089536K
class space used 5213K, capacity 5441K, committed 5632K, reserved 1048576K
}
主要信息:
2017-09-12T21:55:02.954+0800: 239.209: [Full GC (Allocation Failure) 2017-09-12T21:55:02.954+0800: 239.209: [CMS: 1756415K->1756415K(1756416K), 5.4136680 secs] 2063103K->1971243K(2063104K), [Metaspace: 43496K->43496K(1089536K)], 5.4138690 secs] [Times: user=5.41 sys=0.00, real=5.41 secs]
SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(1000);
for(int i=1;i<=pageCount;i++){
int tableNum = i;
int pageIndex = i;
//分页数据查询
List
代码中数据清理、设置空引用都做了,为什么还是不能被回收呢???
jmap使用说明:论持久战之Java性能监控工具(jmap)
重大发现原来是org.apache.poi.xssf.streaming.SXSSFCell、org.apache.poi.xssf.streaming.SXSSFCell$PlainStringValue、org.apache.poi.xssf.streaming.SXSSFRow这三个鬼把内存占完了
SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(1000);
SXSSFCell sxssfCell = null;
SXSSFRow sxssfRow = null;
for(int i=1;i<=pageCount;i++){
int tableNum = i;
int pageIndex = i;
List
程序SXSSFRow、SXSSFCell这两个对象持有一个引用,每当新创建一个对象时候原来引用失效jvm会自动回收
以上属于原创文章,转载请注明作者@怪咖
QQ:208275451
Email:[email protected]