gpt4 book ai didi

java.lang.OutOfMemory错误: GC overhead limit exceeded"while reading excel file using apache POI

转载 作者:行者123 更新时间:2023-12-02 11:00:59 25 4
gpt4 key购买 nike

我们正在使用 Apachi POI 从 Excel 文件中读取数据,它为我们的 Selenium 自动化测试用例提供了 800 行输入数据。我们已经使用 jenkins 进行了配置并执行了批处理作业,它运行良好一年多了。但现在它显示错误“线程“main”java.lang.OutOfMemoryError中的异常:超出GC开销限制”。当我们将 JVM 内存大小增加到 1024 MB 时,它工作正常。 Excel文件大小仅为68KB。但它显示GC错误。您能帮我们看看问题的原因是什么吗?我们如何才能永久解决该问题。

  1. Excel 工作表中的总行数为 800
  2. Excel 工作表文件大小为 68KB

获取错误消息为:

Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded".

请查看随附的屏幕截图以供引用 enter image description here

最佳答案

此错误消息...

Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded".

...意味着您的程序/脚本正忙于垃圾收集,并且 JVM 无法执行任何进一步的任务。

根据Excessive GC Time and OutOfMemoryError如果 总时间的 98% 花费在垃圾收集上,OutOfMemoryError 错误将由 JVM 引发并且少于2%堆内存被回收。引发此错误是为了防止应用程序长时间运行而在没有堆内存的情况下没有任何进展。

解决方案

  • 通过命令行添加选项来关闭显示此错误消息的功能:

    -XX:-UseGCOverheadLimit
  • 通过命令行增加堆大小:

    -Xmx1g

Note: The default maximum heap size can't exceed 1GB limit regardless of how much memory is installed on the machine.

  • 通过命令行对并发集合进行微调:

    -XX:CMSInitiatingOccupancyFraction=<N>
  • 启用增量模式:

    -XX:+CMSIncrementalMode
  • 启用自动节奏:

    -XX:+CMSIncrementalPacing
  • 最后,确保没有 Memory Leaks在您的程序中。

  • 最重要的是,尽可能随时随地重用现有对象以节省内存。

您可以在 Error java.lang.OutOfMemoryError: GC overhead limit exceeded 中找到详细讨论

关于java.lang.OutOfMemory错误: GC overhead limit exceeded"while reading excel file using apache POI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51325353/

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