Multiple calls on conversational component consumes all available memory
------------------------------------------------------------------------
Key: TUSCANY-3999
URL: https://issues.apache.org/jira/browse/TUSCANY-3999
Project: Tuscany
Issue Type: Bug
Affects Versions: Java-SCA-1.6.2
Environment: Mac Os X 10.6.8
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-10M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
Eclipse Version: Helios Service Release 2 Build id: 20110218-0911
Hardware: MacBook pro
Reporter: Petros Pissias
Hello,
I noticed that the consumption of the heap memory steadily increases
with the number of calls during a conversation, and created a simple test where
:
- There is a very simple conversational interface implemented by a component
- a client starts a conversation and loops over calling a method on the target
component
after some seconds I get an OutOfMemoryError :
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at
org.apache.tuscany.sca.core.invocation.MessageImpl.<init>(MessageImpl.java:47)
at
org.apache.tuscany.sca.core.invocation.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:33)
at
org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:321)
at
org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:193)
at $Proxy19.getWord(Unknown Source)
at
tests.sca.performance.TestSCAConversationLeak.main(TestSCAConversationLeak.java:38)
I noticed on VisualVm by inspecting a heap dump, that there are countless
instances related to Executors, FutureTask and ScheduledThreadPoolExecutor.
Below you will find the code I used in order to reproduce the problem:
- Composite
- Main
- Interface
- Component
Composite: resources/conversation_memory.composite
<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
targetNamespace="http://memory_conversation_test.com/"
name="PerformanceTest">
<component name="SimpleComponent">
<implementation.java class="tests.sca.performance.SimpleComponent"/>
<service name="SimpleComponentInterface">
<interface.java
interface="tests.sca.performance.SimpleComponentInterface"/>
</service>
</component>
</composite>
Main Class:
public class TestSCAConversationLeak {
private static SCANode node;
private static Logger logger;
public static void main(String[] args) throws Exception {
logger =
Logger.getLogger(TestSCAConversationLeak.class.getName());
logger.info("Logger initialized");
SCAContribution contrib = new
SCAContribution("conversation_memory.composite", "resources");
node =
SCANodeFactory.newInstance().createSCANode("conversation_memory.composite",
contrib);
node.start();
Thread.sleep(10000); //some time to attach visualvm
SimpleComponentInterface convService1 =
((SCAClient)node).getService(SimpleComponentInterface.class,
"SimpleComponent/SimpleComponentInterface");
while (true){
convService1.getWord("Hello");
}
}
}
Component Interface: tests.sca.performance.SimpleComponentInterface
@Conversational
public interface SimpleComponentInterface {
public String getWord(String in) ;
}
Component Implementation: tests.sca.performance.SimpleComponent
@Scope("CONVERSATION")
@Service(interfaces={SimpleComponentInterface.class})
public class SimpleComponent implements SimpleComponentInterface {
private Logger logger;
public SimpleComponent() {
logger =
Logger.getLogger(TestSCAConversationLeak.class.getName());
logger.info("SimpleComponent instance created");
}
@Override
public String getWord(String in) {
//do nothing, just return the String
return in;
}
}
The same problem can be reproduced in component-to-component communication ,
where the target
component implements a conversational service.
Thanks in advance or your support
and the excellent software.
Petros
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira