gpt4 book ai didi

java.lang.OutOfMemory错误: Java heap space in JasperReports

转载 作者:行者123 更新时间:2023-12-02 08:06:32 24 4
gpt4 key购买 nike

在我的 Swing 应用程序中,当我要打印时,会出现以下异常。但并非总是如此,就像一次三次。在 jasper 报告中执行以下代码时会发生这种情况。我该如何解决这个问题?

    Exception occurred during event dispatching:    java.lang.OutOfMemoryError: Java heap space  
        JRBeanCollectionDataSource datasource = new JRBeanCollectionDataSource(purchasingList);
JasperPrint jasperPrint = JasperFillManager.fillReport(in, params, datasource);

if (view) {// using a JDialog a preview of the print is showed.
new Shows().showJasper(jasperPrint, "Invoice No:" + invoiceNo);
}

final JRPrintServiceExporter exporter = new JRPrintServiceExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
// exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);
exporter.exportReport();

最佳答案

您可以使用 JVM 的 -Xmx 选项。使用更多堆内存启动您的应用程序。
例如

      java -Xmx512M YourClass

关于java.lang.OutOfMemory错误: Java heap space in JasperReports,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8077442/

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