gpt4 book ai didi

java - 获取 java.lang.OutOfMemoryError : GC overhead limit exceeded in Jboss

转载 作者:行者123 更新时间:2023-11-30 03:52:12 25 4
gpt4 key购买 nike

我正在尝试使用 Struts-2 部署一个 Web 应用程序,该应用程序从两个大约 40mb 文件的 Excel 工作表中读取数据并更新它,我将其部署到 Jboss-5 中,但我得到了 java.lang .OutOfMemoryError: GC 开销超出限制 错误。

当我通过 Netbeans 运行简单的 Java 应用程序时使用相同的脚本;最初我遇到了同样的问题,但我通过将 -Xmx 值增加到 2g 来增加 Java 堆内存,然后脚本工作正常。

我也尝试在 Jboss 中增加 -Xmx 值,但有些人再次抛出 java.lang.OutOfMemoryError:超出 GC 开销限制”错误

下面是完整的堆栈跟踪。

java.lang.OutOfMemoryError: GC overhead limit exceeded
at org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.addMultipleBlanks(ValueRecordsAggregate.java:159)
at org.apache.poi.hssf.record.aggregates.RowRecordsAggregate.<init>(RowRecordsAggregate.java:103)
at org.apache.poi.hssf.model.InternalSheet.<init>(InternalSheet.java:208)
at org.apache.poi.hssf.model.InternalSheet.createSheet(InternalSheet.java:163)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:296)
at com.zaxis.tm.utils.ExcelParser.readXldata(ExcelParser.java:84)
at com.zaxis.tm.action.UploadFile.execute(UploadFile.java:231)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)

我遇到问题的方法是

public boolean readXldata(String path,UpdateBean term) {

logger.info("%%%%%%%%%%%%%%%% Inside Reading Export main Fle %%%%%%%%%%%%%%%%");


ExportBean video = null;
HSSFRow myRow = null;
boolean status = false;
ProcessMethods methds = new ProcessMethods();
try{


if(myFileSystem == null){
myFileSystem = new NPOIFSFileSystem(new File(path));
}
if (myWorkBook == null){
myWorkBook = new HSSFWorkbook(myFileSystem.getRoot(),true);
}
if (mySheet == null){
mySheet = myWorkBook.getSheetAt(0);
}
if(mySheet.isColumnHidden(2)){

mySheet.setColumnHidden(2, false);
}
Iterator rowIter = mySheet.rowIterator();

int start = term.getStart_index();

logger.info("TARGET LANG START INDEX ::" +start+ "LAST INDEX ::" +term.getEnd_index());


while(rowIter.hasNext()){



flag = 0;
myRow = (HSSFRow) rowIter.next();
int id = 0;

try{
id = new Double(myRow.getCell(0).toString().trim()).intValue();
logger.info("ID ::" +myRow.getCell(0));

}catch(NumberFormatException nex){
logger.info("\nNUMBER FORMAT EXCEPTION WHIILE READING CONTENT ENTRY IN FILE ::");
continue;
}

}else{
logger.info("\nNUMBER FORMAT EXCEPTION WHIILE READING CONTENT ENTRY IN FILE ::");
continue;
}

video = new ExportBean();

video.setConcept(id);



int Rownum =myRow.getRowNum();
video.setRowno_ex(Rownum);

int LastRow = mySheet.getPhysicalNumberOfRows() - 7 ;




if(myRow.getCell(1)!=null && !myRow.getCell(1).toString().equals("")){
video.setEntryclass(myRow.getCell(1).toString().trim());

}







flag=0;
logger.info("LAST ROW NUMBER ::" +LastRow+" ROW NUMBER ::" +Rownum+ "FLAG ::" +flag);

if(term.getEnglish_term().equalsIgnoreCase(video.getEng_term())){
flag = 1;


if(!term.getTarget_term().equalsIgnoreCase(video.getTar_term())){

logger.info("Termlist English term is same to Export main english term");
logger.info("Termlist English term" +term.getTarget_term()+" is not same to Export main english term");

if(this.Update_Row(video,term)){

logger.info(" ############ ROW NO::"+ video.getRowno_ex() + "SUCCESSFULLY UPDATED #######");
status = true;
return status;
}else{
logger.info(" ############ UPDATION FAILED #########");
return status;
}

}

}else if (LastRow == Rownum && flag == 0){

logger.info("Reached to end of the row");

if(Insert_Row(video,term)){
logger.info("Insertion done successfully at row "+ mySheet.getLastRowNum());

return status=true;

}else{
logger.info("Failed to insert values at the last row");
return status;

}
}

logger.info("Termlist Eng term is not same to main term " +video.getEng_term()+ " Continue with the process.......");

continue;

}

myFileSystem.close();



} catch (Exception e) {
e.printStackTrace();
}

return status;
}

最佳答案

超出 GC 开销限制意味着 JVM 花费了太多时间进行垃圾收集,这通常意味着您没有足够的内存。因此,您可能会出现内存泄漏,您应该启动 jconsole 或 jprofiler 并将其连接到您的 jboss 并在其运行时监视内存使用情况。

暂时增加内存 (Xmx) 至尽可能多的闲置内存也有助于解决此问题。因为如果您可以延迟内存不足,您将有更多时间找到潜在的泄漏

关于java - 获取 java.lang.OutOfMemoryError : GC overhead limit exceeded in Jboss,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24157183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com