这不是一个重复的问题,我看到this,我想运行一个java程序并出现此错误:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at edu.stanford.nlp.ie.crf.CRFLogConditionalObjectiveFunction.empty2D(CRFLogConditionalObjectiveFunction.java:892)
at edu.stanford.nlp.ie.crf.CRFLogConditionalObjectiveFunction.<init>(CRFLogConditionalObjectiveFunction.java:134)
at edu.stanford.nlp.ie.crf.CRFLogConditionalObjectiveFunction.<init>(CRFLogConditionalObjectiveFunction.java:117)
at edu.stanford.nlp.ie.crf.CRFClassifier.getObjectiveFunction(CRFClassifier.java:1792)
at edu.stanford.nlp.ie.crf.CRFClassifier.trainWeights(CRFClassifier.java:1798)
at edu.stanford.nlp.ie.crf.CRFClassifier.train(CRFClassifier.java:1713)
at edu.stanford.nlp.ie.AbstractSequenceClassifier.train(AbstractSequenceClassifier.java:763)
at edu.stanford.nlp.ie.AbstractSequenceClassifier.train(AbstractSequenceClassifier.java:751)
at edu.stanford.nlp.ie.crf.CRFClassifier.main(CRFClassifier.java:2917)
据此我试试这个:
java -Xms2000m -cp stanford-ner.jar edu.stanford.nlp.ie.crf.CRFClassifier -prop fa.prop
但错误没有解决,我再次看到错误!当我设置的值超过2000米时,我的操作系统崩溃了,或者我得到了这个输出:
...
...
//stanford log
...
Time to convert docs to data/labels: 8.8 seconds
Killed
我如何解决它
编辑:
并为此
[stanford-ner]$ java -Xms1G -Xmx50G -cp stanford-ner.jar edu.stanford.nlp.ie.crf.CRFClassifier -prop fa.prop
我有这个错误:
[1000][2000][3000][4000][5000][6000]OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00007f04c7c00000, 1225785344, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 1225785344 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /stanford-ner/hs_err_pid1536.log
答案 0 :(得分:2)
而不是尝试使用Xms选项,
java -Xms2000m -cp stanford-ner.jar edu.stanford.nlp.ie.crf.CRFClassifier -prop fa.prop
尝试使用Xmx,如下所示
java -Xmx2000m -cp stanford-ner.jar edu.stanford.nlp.ie.crf.CRFClassifier -prop fa.prop
参考:Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
答案 1 :(得分:1)
考虑到软件的目的,它可能非常耗费内存,因此可以合理地假设1GB的堆不够,所以你必须进一步增加你的堆大小。
当您尝试暗示您正在使用
时收到的消息这可能会限制你的最大堆大小约为1.5GB(至少在Windows上)。
因此,请确保在64位操作系统上使用64位VM,然后再次尝试增加堆大小。