[
https://issues.jboss.org/browse/DROOLS-1283?page=com.atlassian.jira.plugi...
]
Mario Fusco commented on DROOLS-1283:
-------------------------------------
I reproduced the problem in a simpler way using the test case I'm pasting below. There
isn't any assertion there but you can see the memory occupation constantly increasing
at each loop.
{code}
@Test
public void testCreateKieBaseInLoop() {
final String drl = "package " + this.getClass().getPackage().getName() +
";" +
" rule R1 \n" +
" when \n" +
" String() \n" +
" then \n" +
" end ";
final KieResources kieResources = KieServices.Factory.get().getResources();
final org.kie.api.io.Resource drlResource = kieResources.newByteArrayResource(
drl.getBytes(), "UTF-8" );
drlResource.setTargetPath("src/main/resources/rule.drl");
while (true) {
createKieBase(drlResource);
System.out.println(getUsedMemory());
}
}
private void createKieBase(final org.kie.api.io.Resource... resources ) {
final KieHelper kieHelper = new KieHelper();
for ( org.kie.api.io.Resource resource : resources) {
kieHelper.addResource(resource);
}
kieHelper.build();
}
private long getUsedMemory() {
System.gc();
final Runtime runtime = Runtime.getRuntime();
return runtime.totalMemory() - runtime.freeMemory();
}
{code}
The leak is not a real leak but only caused by the fact that all kcontainers are stored in
this map
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/main...
The kcontainers will be removed by that map when calling dispose() on the single
kcontainer itself. The problem is that nobody is calling that dispose() method, even in
our own KieHelper. Also we are not sure if we want to rely on the fact that the users will
always call that dispose() method (that however is still not exposed in the public API) so
we are still discussing all possible solutions.
Memory leak using KieBuilder.build() method.
---------------------------------------------
Key: DROOLS-1283
URL:
https://issues.jboss.org/browse/DROOLS-1283
Project: Drools
Issue Type: Bug
Components: core engine
Affects Versions: 6.5.0.CR1
Reporter: Tibor Zimányi
Assignee: Mario Fusco
Labels: regression, reported-by-qe
There is a memory leak when building KieBase using KieBuilder.build() method. When
continuously calling kieBuilder.build() (also with no resources), the OOM exception
occurs.
I will make PR with a reproducer for this.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)