Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWRRuleEngine.infer() method causes OutOfMemoryError: GC overhead limit exceeded #42

Open
nmerkle opened this issue Mar 26, 2018 · 3 comments

Comments

@nmerkle
Copy link

nmerkle commented Mar 26, 2018

Hi,
I am using the SWRLAPI inside a simulation framework in order to infer states according to generated triples. In my simulation framework, depending on the iteration size (e.g. 1000 times), I have to call for appropriate times, the infer() method of the SWRLAPIRuleEngine. My method for this, looks like the following code:

public List<String> reasonState() {
		states.clear();
		Set<OWLObjectPropertyAssertionAxiom>myset = null;
		ruleEngine.infer();
		for (final OWLNamedIndividual ini : st.getFlattened()) {
			System.out.println(ini.getIRI().getShortForm());
			for (final Node<OWLNamedIndividual> obj : reasoner.getObjectPropertyValues(ini, pr)) {
				states.add(obj.getRepresentativeElement().getIRI().toString());
				System.out.println(obj.getRepresentativeElement().getIRI().toString());
			}
			myset = ontology.getObjectPropertyAssertionAxioms(ini);
		}
		axioms.addAll(myset);
		
		System.out.println("Axiom Count: "+ontology.getAxiomCount());
		om.removeAxioms(ontology, axioms);
		System.out.println("Axiom Count: "+ontology.getAxiomCount());
		axioms.clear();
		return states;
	} 

So this method is called more than 1000 times. and the program is getting slower and slower until it stands still. Then, after the half of iterations and the according infer() calls I get the following exception:

java.lang.RuntimeException: Cannot call method public void de.fzi.ipe.wim.vCare.simulator.WebsocketClientSession#onMessage(java.lang.String) with args: [java.lang.String]
at org.eclipse.jetty.websocket.common.events.annotated.CallableMethod.unwrapRuntimeException(CallableMethod.java:93)
at org.eclipse.jetty.websocket.common.events.annotated.CallableMethod.call(CallableMethod.java:75)
at org.eclipse.jetty.websocket.common.events.annotated.OptionalSessionCallableMethod.call(OptionalSessionCallableMethod.java:72)
at org.eclipse.jetty.websocket.common.events.JettyAnnotatedEventDriver.onTextMessage(JettyAnnotatedEventDriver.java:225)
at org.eclipse.jetty.websocket.common.message.SimpleTextMessage.messageComplete(SimpleTextMessage.java:69)
at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.appendMessage(AbstractEventDriver.java:64)
at org.eclipse.jetty.websocket.common.events.JettyAnnotatedEventDriver.onTextFrame(JettyAnnotatedEventDriver.java:217)
at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.incomingFrame(AbstractEventDriver.java:160)
at org.eclipse.jetty.websocket.common.WebSocketSession.incomingFrame(WebSocketSession.java:309)
at org.eclipse.jetty.websocket.common.extensions.ExtensionStack.incomingFrame(ExtensionStack.java:214)
at org.eclipse.jetty.websocket.common.Parser.notifyFrame(Parser.java:220)
at org.eclipse.jetty.websocket.common.Parser.parse(Parser.java:258)
at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.readParse(AbstractWebSocketConnection.java:628)
at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.onFillable(AbstractWebSocketConnection.java:476)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded
at sun.reflect.GeneratedConstructorAccessor18.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.io.ObjectStreamClass.newInstance(ObjectStreamClass.java:1079)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2044)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1567)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:427)
at java.util.ArrayList.readObject(ArrayList.java:797)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1158)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2169)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2060)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1567)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:427)
at org.drools.core.rule.Pattern.readExternal(Pattern.java:142)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:2109)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2058)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1567)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:427)
at org.drools.core.rule.From.readExternal(From.java:62)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:2109)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2058)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1567)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:427)
at java.util.IdentityHashMap.readObject(IdentityHashMap.java:1315)
at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1158)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2169)

What could be the reason? I guess that it has something to do with the infer() method call. On other places in my code there are no newly generated objects or unreleased references... So there is no reason to cause memory leaks or to exceed garbage collection limits.

Thanks in advance,
nmerkle

@laotao
Copy link

laotao commented May 18, 2020

Was this solved? I got a similar problem.

@sinamoh
Copy link

sinamoh commented Aug 22, 2020

Same problem here. After iterating for few times, I get garbage collection error (GC overhead limit exceeded). There should be a way to reset the memory.

@PG-9-9
Copy link

PG-9-9 commented Aug 9, 2023

Any solution so far?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants