使用的OutOfMemoryError作为颗粒里森纳(OutOfMemoryError using

2019-09-16 17:10发布

我试图推断使用颗粒数据,但我的应用程序的推理过程中由于老是死机“的OutOfMemoryError:Java堆空间”。

至于其他地方的建议我已经尝试增加堆大小,目前我使用这些VM参数:“-XX:MaxPermSize参数=256米-Xmx6144m”。 此外,我已经设置“PelletOptions.USE_CONTINUOUS =真”,但到目前为止,我只能够延迟了几分钟的crashs。 (最长运行至今:30分钟)。

我在耶拿TDB triplestore存储数据。 它的总容量为170 MB,并且由962117个陈述。 本体已门徒被建模并且存在当与隐士或情况++理由没有不一致性(当然不存在数据在该点)。 我想推断语句已使用等价类建模(例如:A和(hasX一些X)),逆特性(hasX < - > isXOf)和一些传递属性。 有55类:14个类,11等价类(一个根类的所有亚型)。 目前,14个班的情况下,已被添加到tripestore。

我还用pellint来分析我的本体论,但我不知道从这个结果得出结论,其中:

[Untyped classes]
- http://www.w3.org/2002/07/owl#AllDisjointClasses

[Untyped object roles]
- http://www.w3.org/2002/07/owl#topObjectPriority
- http://www.w3.org/2002/07/owl#members

[Untyped datatype roles]
- http://www.w3.org/2002/07/owl#qualifiedCardinality

[Untyped individuals]
- 4 BNodes

这是我创建InfModel代码:

 Dataset dataset = TDBFactory.createDataset(..);
 Model model = dataset.getDefaultModel();

 OntModel ont = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC,model);
 ont.read("file:.." , "RDF/XML");

 PelletOptions.USE_CONTINUOUS_RULES = true;
 Reasoner reasoner = PelletReasonerFactory.theInstance().create();
 reasoner = reasoner.bindSchema(ont);

 InfModel infModel = infModel = ModelFactory.createInfModel(reasoner, model);

这基本上是我如何查询数据:

 QueryExecution qe = QueryExecutionFactory.create("SELECT ...", infModel);
 Resultset rs = qe.execSelect();

 while(rs.hasNext())
 {
     QuerySolution sol = rs.nextSolution();
     ...
 }
 qe.close();

正如你可以看到我已经收到各种异常无论何时查询数据,准备或验证的InfModel。 你有什么想法,有什么事我可以尝试解决这个问题?

 java.lang.OutOfMemoryError: Java heap space
 at java.util.Arrays.copyOf(Unknown Source)
 at java.lang.AbstractStringBuilder.expandCapacity(Unknown Source)
 at java.lang.AbstractStringBuilder.append(Unknown Source)
 at java.lang.StringBuilder.append(Unknown Source)
 at java.net.URLStreamHandler.parseURL(Unknown Source)
 at sun.net.www.protocol.file.Handler.parseURL(Unknown Source)
 at java.net.URL.<init>(Unknown Source)
 at java.net.URL.<init>(Unknown Source)
 at sun.misc.URLClassPath$FileLoader.getResource(Unknown Source)
 at sun.misc.URLClassPath.getResource(Unknown Source)
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorCheck.warn(QueryIteratorCheck.java:114)
 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorCheck.dump(QueryIteratorCheck.java:95)
 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorCheck.checkForOpenIterators(QueryIteratorCheck.java:68)
 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorCheck.close(QueryIteratorCheck.java:50)
 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorWrapper.closeIterator(QueryIteratorWrapper.java:50)
 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.close(QueryIteratorBase.java:184)
 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorCloseable.close(QueryIteratorCloseable.java:39)
 at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.close(QueryExecutionBase.java:180)


 java.lang.OutOfMemoryError: Java heap space
 at shared.SharedObjectFactory.build(SharedObjectFactory.java:303)
 at aterm.pure.PureFactory.makeAppl(PureFactory.java:191)
 at aterm.pure.PureFactory.makeAppl(PureFactory.java:185)
 at aterm.pure.PureFactory.makeAppl(PureFactory.java:228)
 at org.mindswap.pellet.utils.ATermUtils.makeLiteral(ATermUtils.java:245)
 at org.mindswap.pellet.ABox.addLiteral(ABox.java:1696)
 at org.mindswap.pellet.tableau.completion.rule.SomeValuesRule.applySomeValuesRule(SomeValuesRule.java:174)
 at org.mindswap.pellet.tableau.completion.rule.SomeValuesRule.apply(SomeValuesRule.java:64)
 at org.mindswap.pellet.tableau.completion.rule.AbstractTableauRule.apply(AbstractTableauRule.java:64)
 at org.mindswap.pellet.tableau.completion.SROIQStrategy.complete(SROIQStrategy.java:157)
 at org.mindswap.pellet.ABox.isConsistent(ABox.java:1423)
 at org.mindswap.pellet.ABox.isConsistent(ABox.java:1260)
 at org.mindswap.pellet.KnowledgeBase.consistency(KnowledgeBase.java:1987)
 at org.mindswap.pellet.KnowledgeBase.isConsistent(KnowledgeBase.java:2061)
 at org.mindswap.pellet.jena.PelletInfGraph.prepare(PelletInfGraph.java:247)
 at org.mindswap.pellet.jena.PelletInfGraph.prepare(PelletInfGraph.java:230)
 at com.hp.hpl.jena.rdf.model.impl.InfModelImpl.prepare(InfModelImpl.java:89)


 java.lang.OutOfMemoryError: Java heap space
 at org.mindswap.pellet.tableau.branch.DisjunctionBranch.tryBranch(DisjunctionBranch.java:197)
 at org.mindswap.pellet.tableau.branch.Branch.tryNext(Branch.java:117)
 at org.mindswap.pellet.tableau.completion.rule.ChooseRule.apply(ChooseRule.java:82)
 at org.mindswap.pellet.tableau.completion.rule.ChooseRule.apply(ChooseRule.java:56)
 at org.mindswap.pellet.tableau.completion.rule.AbstractTableauRule.apply(AbstractTableauRule.java:64)
 at org.mindswap.pellet.tableau.completion.SROIQStrategy.complete(SROIQStrategy.java:157)
 at org.mindswap.pellet.ABox.isConsistent(ABox.java:1423)
 at org.mindswap.pellet.ABox.isConsistent(ABox.java:1260)
 at org.mindswap.pellet.KnowledgeBase.consistency(KnowledgeBase.java:1987)
 at org.mindswap.pellet.KnowledgeBase.isConsistent(KnowledgeBase.java:2061)
 at org.mindswap.pellet.jena.PelletInfGraph.prepare(PelletInfGraph.java:247)
 at org.mindswap.pellet.jena.PelletInfGraph.prepare(PelletInfGraph.java:230)
 at org.mindswap.pellet.jena.PelletInfGraph.validate(PelletInfGraph.java:564)
 at com.hp.hpl.jena.rdf.model.impl.InfModelImpl.validate(InfModelImpl.java:111)

Answer 1:

查询针对infModel显然造成颗粒产生数百thoundands的owl:differentFrom语句。 该解决方案是使用ModelExtractor

ModelExtractor ext = new ModelExtractor(inf); 
Model m = ext.extractModel();
QueryExecution qe = QueryExecutionFactory.create("SELECT ...", m);


文章来源: OutOfMemoryError using Pellet as Reasoner