I'm trying to infer data using Pellet, but my application always crashes during reasoning due to an "OutOfMemoryError: Java heap space".
As suggested elsewhere I have already tried to increase heap size and currently I am using these VM arguments: "-XX:MaxPermSize=256m -Xmx6144m". Furthermore I've to set 'PelletOptions.USE_CONTINUOUS = true', but so far I was only able delays the crashs for some minutes. (Longest run so far: 30 min.).
I am storing data in a Jena TDB triplestore. Its total size is 170 mb and consists of 962117 statements. The ontology has been modelled in Protege and there are no inconsistencies when reasoned with Hermit or Fact++ (of course no data is present at that point). The statements I'd like to infer have been modelled using equivalent classes (e.g.: A and (hasX some X)), inverse properties (hasX <--> isXOf) and some transitive properties. There are 55 classes: 14 root classes, 11 equivalent classes (all subtype of one root class). At the moment instances of 14 classes have been added to the tripestore.
I also used pellint to analyse my ontology, but I am not sure which conclusions to draw from this result:
[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
This is my code for creating the 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);
and this is essentially how I query the data:
QueryExecution qe = QueryExecutionFactory.create("SELECT ...", infModel);
Resultset rs = qe.execSelect();
while(rs.hasNext())
{
QuerySolution sol = rs.nextSolution();
...
}
qe.close();
As you can see I have received various exceptions when either querying data, preparing or validating an InfModel. Do you have any idea, what else I could try to resolve this error?
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)
Querying against infModel
apparently caused Pellet to generate hundreds of thoundands of owl:differentFrom
statements. The solution was to use ModelExtractor
:
ModelExtractor ext = new ModelExtractor(inf);
Model m = ext.extractModel();
QueryExecution qe = QueryExecutionFactory.create("SELECT ...", m);
来源:https://stackoverflow.com/questions/10279894/outofmemoryerror-using-pellet-as-reasoner