liveontologies / elk-reasoner

A Java-based OWL 2 EL reasoner
Apache License 2.0
94 stars 27 forks source link

java.lang.OutOfMemoryError: unable to create new native thread #36

Open JieyingChenChen opened 8 years ago

JieyingChenChen commented 8 years ago

I am trying to use ELK by owlapi on a server(Linux russell 3.2.0-4-amd64 #1 SMP Debian 3.2.73-2+deb7u2 x86_64). --java version "1.8.0_66" --the ontology I test is snomed CT

The reasoner crashes with the error: Exception in thread "main" java.lang.OutOfMemoryError: unable to create new native thread at java.lang.Thread.start0(Native Method) at java.lang.Thread.start(Thread.java:714) at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:950) at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1357) at org.semanticweb.elk.util.concurrent.computation.ComputationExecutor.start(ComputationExecutor.java:120) at org.semanticweb.elk.util.concurrent.computation.ConcurrentComputation.start(ConcurrentComputation.java:127) at org.semanticweb.elk.reasoner.ReasonerComputation.process(ReasonerComputation.java:90) at org.semanticweb.elk.reasoner.stages.PropertyReflexivityComputationStage.executeStage(PropertyReflexivityComputationStage.java:58) at org.semanticweb.elk.reasoner.stages.AbstractReasonerStage.execute(AbstractReasonerStage.java:184) at org.semanticweb.elk.reasoner.stages.PropertyReflexivityComputationStage.execute(PropertyReflexivityComputationStage.java:28) at org.semanticweb.elk.reasoner.stages.LoggingStageExecutor.execute(LoggingStageExecutor.java:53) at org.semanticweb.elk.reasoner.stages.AbstractStageExecutor.complete(AbstractStageExecutor.java:53) at org.semanticweb.elk.reasoner.stages.AbstractStageExecutor.complete(AbstractStageExecutor.java:47) at org.semanticweb.elk.reasoner.stages.AbstractStageExecutor.complete(AbstractStageExecutor.java:47) at org.semanticweb.elk.reasoner.stages.AbstractStageExecutor.complete(AbstractStageExecutor.java:47) at org.semanticweb.elk.reasoner.stages.AbstractReasonerState.isInconsistent(AbstractReasonerState.java:341) at org.semanticweb.elk.reasoner.stages.AbstractReasonerState.getTaxonomy(AbstractReasonerState.java:383) at org.semanticweb.elk.reasoner.Reasoner.getTaxonomyNode(Reasoner.java:259) at org.semanticweb.elk.reasoner.Reasoner.getEquivalentClasses(Reasoner.java:356) at org.semanticweb.elk.owlapi.ElkReasoner.getEquivalentClasses(ElkReasoner.java:465)

I run the code by using the parameters: -Xmx6G -Xss1024m -Xss1024k

ykazakov commented 8 years ago

Which version of ELK do you use? Also, why do you set -Xss two times? What happens with just -Xmx2G? This should be more than enough for Snomed.

JieyingChenChen commented 8 years ago

I used an earlier version of ELK. But the same error occurred when I tried the latest version of ELK(elk-distribution-0.4.3-owlapi-library.zip) and with the parameters: -Xmx2G -Xss1024m.

The following is the error information: Exception in thread "main" java.lang.OutOfMemoryError: unable to create new native thread at java.lang.Thread.start0(Native Method) at java.lang.Thread.start(Thread.java:714) at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:950) at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1357) at org.semanticweb.elk.util.concurrent.computation.ComputationExecutor.start(ComputationExecutor.java:120) at org.semanticweb.elk.util.concurrent.computation.ConcurrentComputation.start(ConcurrentComputation.java:146) at org.semanticweb.elk.reasoner.ReasonerComputation.process(ReasonerComputation.java:90) at org.semanticweb.elk.reasoner.stages.PropertyReflexivityComputationStage.executeStage(PropertyReflexivityComputationStage.java:57) at org.semanticweb.elk.reasoner.stages.AbstractReasonerStage.execute(AbstractReasonerStage.java:165) at org.semanticweb.elk.reasoner.stages.PropertyReflexivityComputationStage.execute(PropertyReflexivityComputationStage.java:28) at org.semanticweb.elk.reasoner.stages.LoggingStageExecutor.execute(LoggingStageExecutor.java:53) at org.semanticweb.elk.reasoner.stages.AbstractStageExecutor.complete(AbstractStageExecutor.java:55) at org.semanticweb.elk.reasoner.stages.AbstractStageExecutor.complete(AbstractStageExecutor.java:51) at org.semanticweb.elk.reasoner.stages.AbstractStageExecutor.complete(AbstractStageExecutor.java:51) at org.semanticweb.elk.reasoner.stages.AbstractStageExecutor.complete(AbstractStageExecutor.java:51) at org.semanticweb.elk.reasoner.stages.AbstractReasonerState.complete(AbstractReasonerState.java:145) at org.semanticweb.elk.reasoner.stages.AbstractReasonerState.isInconsistent(AbstractReasonerState.java:290) at org.semanticweb.elk.reasoner.stages.AbstractReasonerState.getTaxonomy(AbstractReasonerState.java:324) at org.semanticweb.elk.reasoner.Reasoner.getTaxonomyNode(Reasoner.java:260) at org.semanticweb.elk.reasoner.Reasoner.getEquivalentClasses(Reasoner.java:357) at org.semanticweb.elk.owlapi.ElkReasoner.getEquivalentClasses(ElkReasoner.java:471)

ykazakov commented 8 years ago

Thanks for your report! I am not sure how to diagnose this. Does this problem happen on every run or only occasionally? Can you make a thread dump to see if any ridiculous number of threads is created? Do you use any custom elk.properties file, in which, e.g., the number of workers is set? Can you set the log level to DEBUG and paste the log output?

ykazakov commented 8 years ago

@JieyingChenChen do you still have this problem or it has been resolved? If so, could you, please, comment what you did to prevent it?

spolavar commented 8 years ago

@ykazakov and @JieyingChenChen, I am still experiencing randomly occurring java.lang.OutOfMemoryError error. But whenever this happens it just brings down my entire application. Here is the typical error I find:

"SEVERE: The web application [/neuroMorphoReview] appears to have started a thread named [elk-reasoner-thread-2] but has failed to stop it. This is very likely to create a memory leak."

Seem like every request I make, it is spawning some 12 threads, which are not being freed, and over time when it hits the cap, which is a default setting controlled by the tomcat container it is bringing down the application, and i see this error:

"Exception in thread "http-bio-8080-exec-21905" java.lang.OutOfMemoryError: unable to create new native thread" I am using the elk-owlapi 0.4.3 version, and i create my reasoner object whenever needed by calling a static method, ceateReasoner.

reasoner = createReasoner(o);//o is OWLOntology object reasoner.flush();

Any thoughts on how to trace and fix this problem will be of great help!

Thank you, Sridevi

ykazakov commented 8 years ago

@spolavar ELK indeed creates threads (by default as many as there are native threads on the machine) for every reasoning request, but they should terminate when the reasoning request finishes. Can you make a thread dump of your application and post it here so that I can check how many threads are created and where they got "stuck"? Also, if you create a reasoner many times, do you call reasoner.dispose() after you are done?