gpt4 book ai didi

java.lang.OutOfMemory错误: Java heap space importing a serialized file in eclipse

转载 作者:行者123 更新时间:2023-11-30 08:12:01 24 4
gpt4 key购买 nike

当我尝试在主程序中导入序列化文件时,程序停止工作并抛出:线程“main”java.lang.OutOfMemoryError中的异常:Java堆空间。我知道这个异常可能会因为内存不足而抛出,但我不认为这是这种情况的原因。我的电脑有 8GB RAM。这是Eclipse的.ini文件:

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20150204-1316
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
1024M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
1024m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms512m
-Xmx7500m
-XX:+UseConcMarkSweepGC
-XX:-UseGCOverheadLimit

我注意到虽然 eclipse 可以使用我电脑的几乎所有内存,但当发生此错误时,使用的 RAM 大约只有 5Gb。我尝试导入的文件大小为 500Mb。同一个程序适用于许多 350Mb 的文件。这是程序崩溃的代码行,也是我程序的第一行:

Classifier cls1 = (Classifier) weka.core.SerializationHelper.read("C:\\Users\\.....\\FileToImport.model");

谁知道呢,我正在使用 Weka 库。谢谢您的解答!

最佳答案

“eclipse.ini”文件设置 Eclipse 本身的内存,而不是您的程序。

要设置程序的内存,请打开“运行 > 运行配置”对话框。在“Java 应用程序”部分中找到您的程序,并在“参数 > VM 参数”部分中指定所需的 -Xmx 选项。

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

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